plupload似乎没有在IE 9中上传文件。它适用于其他浏览器

在我们的项目中,我们使用plupload上传单个excel文件。 这适用于IE9以外的所有浏览器。 单击上载链接时,将显示文件对话框,但尝试打开Excel时没有任何反应。 以下是供参考的代码,我们非常感谢您解决此问题的任何帮助。 提前致谢!

function initUploader(btnId, fileType, onSuccess) { if (typeof fileType == "undefined") fileType = "image"; var arrFilters = new Array(); var url = 'user/attachmentUpload'; switch (fileType) { case "image": arrFilters = [{title : "Image files", extensions : "jpg,jpeg,gif,png"}]; url = 'assets/imgupload'; break; case "xls": arrFilters = [{title : "Spreadsheet files", extensions : "xls,xlsx"}]; url = 'user/attachmentUpload'; break; case "media": arrFilters = [{ title : "Media files", extensions : "mpeg4,mob,3gpp,avi,wmv,mp3,m4a,ogg,wav" }]; break; case "document": arrFilters = [{ title : "Text files", extensions : "doc,docx" },{ title : "PDF files", extensions : "pdf" }]; break; default: arrFilters = [ { title : "Image files", extensions : "jpg,jpeg,gif,png" }, { title : "Zip files", extensions : "zip" }, { title : "Media files", extensions : "mpeg4,mob,3gpp,avi,wmv,mp3,m4a,ogg,wav" }, { title : "Spreadsheet files", extensions : "xls,xlsx" }, { title : "Text files", extensions : "doc,docx" }, { title : "PDF files", extensions : "pdf" } ]; break; } var uploader = new plupload.Uploader({ runtimes : 'gears,html5,html4,flash,silverlight,browserplus', browse_button : btnId, //container : 'container', max_file_size : '10mb', url : url, flash_swf_url : 'assets/js/vendor/plupload/plupload.flash.swf', silverlight_xap_url : 'assets/js/vendor/plupload/plupload.silverlight.xap', multiple_queues : false, filters : arrFilters, resize : {width : 320, height : 240, quality : 90} }); $('#'+btnId).change(function(){ uploader.start(); }); uploader.refresh(); uploader.init(); uploader.bind('FilesAdded', function(up, files) { up.refresh(); // Reposition Flash/Silverlight Utility.showProcessingBar(); uploader.start(); }); uploader.bind('Error', function(up, err) { alert("Error: " + err.code + ", Message: " + err.message + (err.file ? ", File: " + err.file.name : "")); up.refresh(); // Reposition Flash/Silverlight }); uploader.bind('FileUploaded', function(up, file, response) { var obj = eval('(' + response.response + ')'); //alert('Files uploaded'); if (typeof onSuccess == "function") onSuccess(obj.fileName); }); } 

对于遇到与我相同问题的每个人:

我有以下HTML代码:

  

container创建为对话框:

 $(function(){ $(".container").dialog({modal:true, width:400}); }); 

我们知道div最初是由于display: none隐藏的display: none (当然,你可以设置autoOpen:false作为对话框对象中的新选项),我们可以删除样式。

在IE8中(可能在早期版本和更高版本中),如果div被隐藏,则无法正确实例化上传器。 (返回上述错误)

在Chrome和Firefox中(我没有在Opera中测试过这个问题),它运行正常。

所以,我的建议是避免隐藏的块(即使你想创建一个modal dialog)。

我从该div删除了display:none style和dialog对象,现在它在IE8中运行得非常好。

为什么? 我不知道为什么在IE中,对象的实例不是在页面启动时创建的,尽管在Firefox和Chrome中,实例是正常创建的。

为获得最大兼容性,您应重新安排插件优先级列表。

  var uploader = new plupload.Uploader({ runtimes : 'gears,html5,html4,flash,silverlight,browserplus', 

用它代替

  var uploader = new plupload.Uploader({ runtimes : 'flash,html5,silverlight,browserplus,gears,html4', 

确保Flash文件存在且路径相对于js文件的位置。

 flash_swf_url : 'assets/js/vendor/plupload/plupload.flash.swf', 

我正在使用这个jquery。

你可以试试这个,因为我在ie7 +和我的文件上传所有浏览器中使用它。

这是我是新手如何在这里上传js文件的文件代码。

 

例子可以从我的小提琴中找到。

有一个快乐的编码:)

现场演示使用ie7 http://vasplus.info/demos/upload_without_page_refresh/index.php