Blueimp 将上传触发器添加到多个输入
Blueimp adding upload trigger to multiple inputs
我的页面上有两个带有 type="file"
的输入
<input class="form-control" type="file" id="uploadImageFileSingle"> <br>
<input id="fileupload" type="file" name="files[]" multiple>
第一个输入是上传单个文件的普通输入。 blueimp 使用第二个输入来上传多个文件,并像这样初始化:
$('#fileupload').fileupload({
url: url,
dataType: 'json',
....
})
除此之外一切正常:当我将文件添加到第一个输入时,它触发了 blueimp 的 fileuploadadd
方法,并且文件被添加到要上传的 blueimp 队列中。我无法想象 how/why 这正在发生。
如何调整 blueimp 获取的输入?
如果你有按钮
<button id="upload_btn">Multiple Upload</button>
你可以试试
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
var that = this;
$.blueimp.fileupload.prototype.options.add.call(that, e, data);
$("#upload_btn").on('click', function () {
data.submit();
});
},
});
也许它控制加载多个文件的更好方式
这是一个解决方法:
$("#uploadImageFileSingle").off() // removes all handlers from first input
请注意,这将从该输入元素中删除 all 处理程序,但它对我有用,因为它还删除了由 blueimp 添加的处理程序(仍然无法弄清楚在哪里添加!)。
我的页面上有两个带有 type="file"
的输入
<input class="form-control" type="file" id="uploadImageFileSingle"> <br>
<input id="fileupload" type="file" name="files[]" multiple>
第一个输入是上传单个文件的普通输入。 blueimp 使用第二个输入来上传多个文件,并像这样初始化:
$('#fileupload').fileupload({
url: url,
dataType: 'json',
....
})
除此之外一切正常:当我将文件添加到第一个输入时,它触发了 blueimp 的 fileuploadadd
方法,并且文件被添加到要上传的 blueimp 队列中。我无法想象 how/why 这正在发生。
如何调整 blueimp 获取的输入?
如果你有按钮
<button id="upload_btn">Multiple Upload</button>
你可以试试
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
var that = this;
$.blueimp.fileupload.prototype.options.add.call(that, e, data);
$("#upload_btn").on('click', function () {
data.submit();
});
},
});
也许它控制加载多个文件的更好方式
这是一个解决方法:
$("#uploadImageFileSingle").off() // removes all handlers from first input
请注意,这将从该输入元素中删除 all 处理程序,但它对我有用,因为它还删除了由 blueimp 添加的处理程序(仍然无法弄清楚在哪里添加!)。