【发布时间】:2013-05-25 23:21:00
【问题描述】:
使用 blueimp 的 jQuery-File-Upload https://github.com/blueimp/jQuery-File-Upload
我的应用程序在许多旧版浏览器上运行。文件上传有很长的兼容性限制列表。 我想简单地检测文件上传器何时优雅地回落到使用 iframe 传输。 我想在使用文件上传的 jQuery 中检测到这一点,类似于此示例:
var using_iframe_transport = false;
this_file_input.fileupload({
dataType: 'json',
url: "http://api.cloudinary.com/v1_1/my_account/image/upload",
//as we send the file upload, record whether it is using iframe
send: function (e, data) {
if (e.iframe_fallback){ //is there a variable like this that exists in the plugin?
using_iframe_transport = true;
}
}
});//end fileupload
if (using_iframe_transport){
//do something
}
可以在 'progress'、'done' 或 'always' 回调中使用此代码:
...
progress: function(e){ //or 'done' or 'always'
if($('iframe').length){
using_iframe_transport = true;
}
}
...
但是,这些回调并不总是像 https://github.com/blueimp/jQuery-File-Upload/issues/461#issuecomment-9299307 报告的那样进行
我最大的担忧是支持 IE6 和 Android 2.3 默认浏览器。谢谢!
【问题讨论】:
标签: jquery iframe file-upload blueimp cloudinary