我正在为一个系统使用模板。但是,我不知道如何将input:file连接到input:text和input:button。似乎input:file隐藏在这个模板中,我必须使用input:text(它被禁用)和input:按钮。代码如下:
<div class="form-group">
<label>File upload</label>
<input type="file" name="img[]" class="file-upload-default">
<div class="input-group col-xs-12">
<input type="text" class="form-control file-upload-info" disabled="" placeholder="Upload Image">
<span class="input-group-append">
<button class="file-upload-browse btn btn-info" type="button">Upload</button>
</span>
</div>
</div>我必须把它用在multer身上。我怎样才能传递数据呢?甚至是多次上传。抱歉的。感恩节。
发布于 2018-10-03 23:59:12
尝尝这个
<html lang="en">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<head>
<body>
<div class="form-group form-file" >
<label>File upload</label>
<input type="file" name="img[]" class="file-upload-default" id="file-1" style="display:none" onchange="checkFile(this)">
<div class="input-group col-xs-12">
<input type="text" class="form-control file-upload-info" disabled="" placeholder="Upload Image">
<span class="input-group-append">
<button class="file-upload-browse btn btn-info" type="button" onclick="$('#file-1').click()">Upload</button>
</span>
</div>
</div>
</body>
<script type="text/javascript">
var count_file=1;
function checkFile(dom){
if($(dom)[0].files[0]){
console.log($(dom).parent().find('.file-upload-info'));
var d=$(dom).parent().find('.file-upload-info')[0];
d.value=($(dom)[0].files[0].name);
}
}
</script>
</script>
https://stackoverflow.com/questions/52629953
复制相似问题