使用 IE 8 重置会话进行上传(服务器端是带有 Devise 的 Rails 3)
我有一个超级简单的用户个人资料页面。用户登录,进入个人资料页面并上传个人资料照片。对于上传,我使用 Uploadify 和通常的会话 hack。
在 FF5、Safari 和 Chrome 中一切正常,但当我在 IE 8 上测试时,我看到以下行为:
- uploadify 正确上传照片,
- 但当我单击“保存”按钮保存配置文件时,服务器将我重定向到登录页面。
一项小小的调查表明,在调用 Uploadify 后,IE 似乎会销毁其中包含会话的 cookie,因此使用几乎已注销。
非常感谢任何帮助。谢谢, -马泰奥
I have a super simple user profile page. The user logs in, go the profile page and upload a profile photo. For the upload I use Uploadify with the usual session hack.
Everything works perfectly in FF5, Safari and Chrome but when I test on IE 8 I see the following behavior:
- uploadify upload the photo correctly
- but when I click on the "save" button to save the profile the server redirects me to the signin page.
A little investigation has shown me that after the call to Uploadify it seems that IE destroys the cookies with the session in it therefore the use is pretty much logged out.
Any help is really appreciated. Thanks,
-Matteo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过添加以下内容解决了该问题:protect_from_forgery : except => :创造
到assets_controller,这是用于上传文件的控制器。
Solved the issue by adding: protect_from_forgery :except => :create
to the assets_controller, this is the controller used to upload files.
对于其他来到这里的人,请查看:
Rails Carrier Wave with JQuery Uploader
更深入地了解如何设置 csrf-param 和 csrf-token,以便载波与 Rails 一起工作。
For others who come here, check out:
Rails Carrier Wave with JQuery Uploader
It goes into a little more depth on how to set csrf-param and csrf-token so that carrier wave works with Rails.