swfupload 上传多图片在 chrome 上正常,safari 和 firefox 上出错报的是日志显示 401 错误 下面是日志信息
Started POST "/ reply_messages/upload_ajax" for 127.0.0.1 at 2015-07-12 20:15:54 +0800
Processing by ReplyMessagesController#upload_ajax as HTML
Parameters: {"Filename"=>"1.pic.jpg", "uploadfile"=>#<ActionDispatch::Http::UploadedFile:0x007fc4dd789480 @original_filename="1.pic.jpg", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"uploadfile\"; filename=\"1.pic.jpg\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<File:/var/folders/27/2ykltwhs56jdgcd51hz4wz1w0000gn/T/RackMultipart20150712-43675-e2jmrj>>, "Upload"=>"Submit Query"}
Completed 401 Unauthorized in 1ms
网上有说是因为 cookie 没有传到服务器的问题 我在 swfupload 中加入了
post_params:{'session_id': '<%= cookies[:_session_id] %>','authenticity_token':'<%= form_authenticity_token.to_s %>'},
完整如下
$('#myModal #swfupload-control').swfupload({
upload_url: "/ reply_messages/upload_ajax",
post_params:{'session_id': '<%= cookies[:_session_id] %>','authenticity_token':'<%= form_authenticity_token.to_s %>'},
file_post_name: 'uploadfile',
file_size_limit : "2048",
file_types : "*.jpg;*.bmp;*.jpeg;*.png;*.gif",
file_types_description : "Image files",
file_upload_limit : 5,
flash_url : "/jquery-swfupload/js/swfupload/uploadify.swf",
button_image_url : '/img/wdp_buttons_upload_114x29.png',
button_width : 114,
button_height : 29,
button_placeholder : $('#myModal #button')[0],
debug: false
})
但还是相同问题 请问谁怎么要怎么改 知道的麻烦回复下感谢