SWFUpload的cookie Bug解决方法

最近用swfupload做图片上传,发现cookie值无法取得。

使用firefox和chrome无法取得cookie值。

调查之,发现时flashplayer的bug,windows下非IE浏览器上传的实际上也是IE浏览器的cookie值。而且到现在adobe也没有要解决这个东西的意图。

Cookie issue

On Windows the Non-IE Flash Player plugin (FireFox, Opera, Safari, etc) sends the IE cookies regardless of the browser used. This breaks authentication and sessions for many server-side scripting technologies.

Developers should manually pass Session and Authentication cookie information and manually restore Sessions on the Server Side if they wish to use Sessions

The SWFUpload package contains work-around sample code for PHP and ASP.Net

 

解决办法无非只能是把cookie通过request参数传递到服务器端。

swfupload提供了一个插件,swfupload.cookies.js。

Cookies

In response to the Flash Cookie Bug the Cookies Plugin automatically retrieves your browser's cookies and sends them with the uploads. The are sent as POST or GET variables to the upload url.

 

这个插件会自动帮你把cookie的值转换并设置到request的param中。

注:如果自己也需要向request中设置param的话,不要使用它提供的setPostParams方法,这样会将cookie插件设置的cookie值覆盖掉,只能通过addPostParam方法追加(注意方法名,顾名思义,只能一次追加一个参数)。


引入这个js即可。


然后在action中自己取得request中的参数即可。

 

另外一个注意点:原始cookie是通过文件头传递的,而上面的处理方式就变成url传递了,所以url里面某些字符被转义了,在action中取得后要进行decode操作才行。

转载于:https://my.oschina.net/jing31/blog/9005

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值