我有一个文件上传器模仿Ryan Bates railscast,它可以在任何支持XHR请求的浏览器中完美运行,但我无法弄清楚为什么IE8没有向服务器发出正确的请求。
我的表单看起来像这样:
<form accept-charset="UTF-8" action="/users/paul-zaich/avatars" class="" enctype="multipart/form-data" id="new-uploaded-avatar" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="8K3821XQAVK8//GR2tqNFPuil+KMn1nP8MMXefPSczY="></div>
<div class="text-center photo-uploader">
<div class="hide">
<input accept="image/*" class="hidden-file-field" id="avatar_photo" name="avatar[photo]" type="file">
</div>
<a href="#" class=" btn btn-primary manual-filechooser">
<i class="icon-plus-sign"></i> Select a photo
</a> <span class="avatar-help-text">or drag and drop your photo here. (.jpg, .png, .gif formats)</span>
</div>
</form>
通常在上传文件时,我会收到这样的请求
Started POST "/users/paul-zaich/avatars" for 127.0.0.1 at 2013-10-02 16:29:57 -0700
Chrome 29.0.1547.76 (Macintosh, OS X 10.8.4), JS enabled
Processing by AvatarsController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"8K3821XQAVK8//GR2tqNFPuil+KMn1nP8MMXefPSczY=", "avatar"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x007fbfc1a1bd68 @original_filename="Screen Shot 2013-10-02 at 6.07.02 AM.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"avatar[photo]\"; filename=\"Screen Shot 2013-10-02 at 6.07.02 AM.png\"\r\nContent-Type: image/png\r\n", @tempfile=#<File:/var/folders/_8/xgsyh3453f52nj6gtn64yh580000gn/T/RackMultipart20131002-6891-xix1c2>>}, "user_id"=>"paul-zaich"}
然而,对于IE8,它似乎完全忽略了表单和方法类型中的动作URL。这是我的服务器日志的样子
Started GET "/settings/[object%20Object]" for 172.16.130.1 at 2013-10-02 16:20:56 -0700
Internet Explorer 8.0 (Windows, Windows 7)
Processing by UsersController#edit as */*
Parameters: {"id"=>"[object object]"}
我的fileupload调用看起来像这样(简化)
$('#new-uploaded-avatar').fileupload({
dataType: 'script',
dropZone: $('.user-avatar-uploader-container'),
add: function (e, data) {
data.context = $(tmpl("avatar-upload", data.files[0]));
$('.photo-uploader').hide();
$('.upload-catch').append(data.context);
data.submit();
}
});
有什么想法吗?