这里:https ://github.com/blueimp/jQuery-File-Upload/wiki/Frequently-Asked-Questions
我读到这个:如果你定义了 url(可能还有 paramName)选项,你可以在任何元素上调用插件——不需要表单或文件输入字段——并且拖放功能仍然有效。
我试过这段代码:
JS
$(".resultUpload").each(function () {
$(this).fileupload({
url: '/results/upload-ajax',
formData: {
//staff
},
dataType: 'json',
maxFileSize: 10000000, // 10 MB
paramName: 'fileupload',
fileInput: $('input:file'),
basic: true,
maxNumberOfFiles: 1,
done: function (e, data) {
console.log('done');
//staff
},
progressall: function (e, data) {
console.log('progressall');
//staff
},
fail: function (e, data) {
console.log('fail');
//staff
}
});
});
HTML
<div class="span3">
<label>Attachment</label>
<div class="file-upload">
<span class="btn btn-inverse fileinput-button">
<span>Select File</span>
<input type="text" buttontext="Select File" class="resultUpload span12" value="" id="attachment" name="attachment"/>
</span>
<br/>
<br/>
<!-- The global progress bar -->
<div class="progress progress-success progress-striped">
<div class="bar"></div>
</div>
</div>
jsfiddle:http: //jsfiddle.net/JellyBelly/hHZUq/
如果我单击按钮不打开窗口浏览文件。我哪里错了?
如果我将输入类型更改为文件工作。
谢谢