jQuery File Uploader IE9不在Upload上发布任何参数

我正在使用jQuery文件上传器插件以及rails 3.插件在这里:

https://github.com/blueimp/jQuery-File-Upload

我正在使用该插件允许用户上传个人资料照片。 到目前为止,该解决方案适用于Chrome,Safari和Firefox。 但是在IE上失败了。 当你在IE中选择一个文件时,插件会发布到服务器但是没有参数,这是一个空post。

chrome中的post示例:

Started PUT "/api/1/settings/ajax_photo_upload" for 10.0.1.3 at 2012-10-02 15:39:20 -0700 Processing by ApiV1::SettingsController#ajax_photo_upload as JS Parameters: {"photo"=>#<ActionDispatch::Http::UploadedFile:0x007f9e4bac2e48 @original_filename="xxxxx.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[photo]\"; filename=\"xxxxx.jpeg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#>}, "update_type"=>"general"} 

但是在IE9中,它不会发送任何内容:

 Started PUT "/api/1/settings/ajax_photo_upload" for 10.0.1.10 at 2012-10-02 15:39:31 -0700 Processing by ApiV1::SettingsController#ajax_photo_upload as JS 

这是我的实施:

 $('input[type="file"]').fileupload({ url : '/api/1/settings/ajax_photo_upload', formData : [{ name : 'authenticity_token', value : $('meta[name="csrf-token"]').attr('content') }], type : 'PUT', dataType: 'json', add : function (e, data) { data.submit(); } }); 

HTML

  

任何想法为什么IE会这样做? 谢谢

你在使用基本的插件吗? 我和我有同样的问题,并与它斗争了一天只是为了意识到我没有包含jquery.iframe-transport.js插件:

  

请参阅此处的文档

哦! 并感谢您关于将’authenticity_token’键值对包含为’formData’的片段 – 这有助于我摆脱rails 3警告“警告:无法validationCSRF令牌真实性”

它基本上是关于html 5的数据标签的支持。 IE9有严重的问题。 例如,当您上传图像时,在Chrome中它会搜索数据:blob并在实际上传图像之前为您提供预览。 在IE中,你不能。 在IE9中查看Gmail的邮件附件屏幕,您将看到不同之处。 如果是大型项目,我建议你使用flash作为图像上传器。

  $("#txt1").fileupload({ replaceFileInput: false, dataType: "json", datatype:"json", url: "<%=Page.ResolveUrl("~/WebService/AddAttachment.ashx")%>", done: function (e, data) { $.each(data.result, function (index, value) { //You get the response data in here from your web service }) $("#txt1").val(""); }`enter code here` }); 

这在IE8和IE9 +上面都经过测试并正常工作。 请确保使用正确的dataType:“json”(或数据类型:“json”),并确保在调试和检查时,Web服务方法的响应已正确更新为data.result。 谢谢