您的位置:首页 > Web前端

Firefox中使用FileReference上传文件的问题:Session丢失

2010-06-23 16:13 579 查看
在Flex中使用FileReference上传文件的时候,遇到了一个很怪的问题。文件上传在IE中一切正常,而在Firefox中总是失败。Debug后发现,firefox中上传文件时,请求总是没有验证。用google一把,发现原因是: Firefox中,FileReference使用的URLRequest和Flash所在页面用的不同的Session. 所以即使你已经登录,由于上传的请求用的是不同的Session,服务器无法得知请求已经验证。 Adobe文档如此解释

The FileReference and FileReferenceList classes also do not providemethods for authentication. With servers that require authentication,you can download files with the Flash® Player browserplug-in, but uploading (on all players) and downloading (on thestand-alone or external player) fails. Listen for FileReference eventsto determine whether operations complete successfully and to handleerrors.
翻译过来就是 FileReference 不支持验证功能。 解决方法 1. 不使用FileReference,而使用form post上传文件。这样和普通的Html页面一样了。 2. 将Session id传到服务器。 如果你使用的Server是TomCat/JSP 可以如下添加SessionID. var request:URLRequest = new URL Request("http://www.[your url].com" + ";jsessionid=" _yoursessionid); 3. 不验证Session,而检查上传ID。比如每次上传前,服务器生成一个ID,上传的时候把这个传ID作为URLRequest的参数传过去。 4. 等待adobe发布hotfix. 有人知道怎么在Asp.net中把Session ID和URL一起传到服务器,而且服务器使用这个SessionID表示的Session吗? 我没有找到答案。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐