我正在使用与Rails 3一起的jQuery文件上传插件。 插件链接如下:https://github.com/blueimp/jQuery-File-Upload。
我使用该插件允许用户上传个人资料照片。 到目前为止,该解决方案在Chrome、Safari和Firefox上运行良好。 但是,在IE上失败。 在IE中选择文件后,插件会向服务器发送POST请求,但没有参数,它是一个空POST请求。
例如,Chrome中的POST请求:
然而在IE9中,它不会发送任何内容:
这是我的实现代码:
有什么想法可以解释IE为什么会这样做吗?谢谢。
我使用该插件允许用户上传个人资料照片。 到目前为止,该解决方案在Chrome、Safari和Firefox上运行良好。 但是,在IE上失败。 在IE中选择文件后,插件会向服务器发送POST请求,但没有参数,它是一个空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=#<File:/var/folders/3x/k1yb0r4s07q1jm82kq93ch180000gn/T/RackMultipart20121002-3633-sxsbtu>>}, "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
<input name="user[photo]" type="file" accept="image/*" >
有什么想法可以解释IE为什么会这样做吗?谢谢。