简体   繁体   English

BlueImp文件上传插件不起作用

[英]BlueImp file upload plugin not working

I have a page that has the following input elemet: 我有一个页面,其中包含以下输入要素:

 <input class="uploadDocument" type="file" name="FileData" id="my-upl" /> 

And then the following javascript for starting the upload: 然后使用以下JavaScript开始上传:

 $("#my-upl").fileupload({ url: uploadUrl, dataType: 'string', done: successFunction, uploadProgress: function(e, data) { var pct = parseInt(data.loaded / data.total * 100, 10); updateProgressBar(progressDiv, progressBar, progressLabel, Math.round(pct)); }, fail: function(e, data) { var errorHtml = uploadFailedHtml + "<p>" + data.textStatus + "</p>"; showModal(uploadFailedTitle, errorHtml); } }); 

It seems that the file upload does not trigger. 文件上传似乎没有触发。 I've even tried specifying a "start" and an "always" callback to see if anything gets triggered but to no avail. 我什至尝试指定“开始”和“始终”回调,以查看是否触发了任何操作但无济于事。

EDIT: I've added an "add" callback and this does get triggered when the file is selected but the upload does not start. 编辑:我添加了一个“添加”回调,当选择了文件但上传没有开始时,确实会触发该回调。

The answer was found by looking at what code is run when using a button to start the upload 通过查看使用按钮开始上传时运行的代码找到了答案

In my add callback, I simply had to do data.submit() : 在我的添加回调中,我只需要做data.submit()

 $("#my-upl").fileupload({ url: uploadUrl, dataType: 'string', done: successFunction, uploadProgress: function(e, data) { var pct = parseInt(data.loaded / data.total * 100, 10); updateProgressBar(progressDiv, progressBar, progressLabel, Math.round(pct)); }, fail: function(e, data) { var errorHtml = uploadFailedHtml + "<p>" + data.textStatus + "</p>"; showModal(uploadFailedTitle, errorHtml); }, add: function(e, data) { data.submit(); return true; } }); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Blueimp文件上传插件只上传一次 - Blueimp File Upload Plugin uploads only once 如何使用 blueimp 文件上传插件只上传一次文件? - How to upload a file only once with blueimp file upload plugin? blueimp jQuery-File-Upload无法正常工作 - blueimp jQuery-File-Upload not working 无法中止针对blueimp文件上传插件的&#39;fileuploadchunkdone&#39;事件处理程序上的上传 - Unable to abort upload on 'fileuploadchunkdone' event handler for blueimp file upload plugin blueimp文件上传插件中的maxFileSize和acceptFileTypes不起作用。为什么? - maxFileSize and acceptFileTypes in blueimp file upload plugin do not work. Why? blueimp / jQuery-File-Upload模板上传在zend Framework 2中不起作用 - blueimp / jQuery-File-Upload template upload not working in zend framework 2 blueimp jQuery文件上传插件隐藏上传的文件 - blueimp jQuery file upload plugin hide uploaded files 在IE8 / 9中使用blueimp文件上传插件的jQuery $ _FILES数组为空 - jQuery $_FILES array empty with blueimp file upload plugin in IE8/9 有什么想法为什么我的blueimp jQuery文件上传脚本不起作用? - Any ideas why my blueimp jQuery file upload script is not working? blueimp jquery文件上传 - “完成”,“完成”回调不适用于IE 9 - blueimp jquery file upload - “done”, “complete” callbacks not working for IE 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM