如何让Flex文件上传在Firefox和Safari浏览器上工作? [英] How do I make Flex file upload work on firefox and safari?

查看:160
本文介绍了如何让Flex文件上传在Firefox和Safari浏览器上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个flex应用程序,可以将文件上传到服务器。服务器需要认证才能上传。在IE中,上传工作正常。但是在FF和Safari中,它不会上传。我已经看到了所有人都有这个相同的问题,但没有答案。现在不要让我失望。

解决方案

我在尝试自己找到答案时发现了这个问题。解决的办法很简单。



基于其他人链接的flash播放器bug,以及该网页上的评论,我决定将会话标识符附加到我的上传网址,并给它一个镜头。这真的很简单!

为了使它工作,我开始添加一个名为sessionParams的flashVar参数。这允许我把我想要的任何字符串作为我的会话标识符传递给flash播放器,并且稍后会将其附加到用于上传的URL。

  // sessionParams  - 解决firefox上传bug 
public var sessionParams:String =;
$ b // ...

public function initApp():void {
sessionParams = Application.application.parameters.sessionParams;



$ b $ p
$ b

在我的例子中,我在启用java会话的ColdFusion上,所以我的

  sessionParams 在传入Flash播放器之前设置如下>< cfset flashVars =sessionParams =#urlEncodedFormat('jsessionid ='& session.sessionid)#/> 

不要忘记转义特殊字符,例如=,&与urlEncodedFormat),以便它们被视为sessionParams参数值的一部分,而不是断点来指示其他参数。您将future-URL信息嵌入到当前URL中。

然后,在上传代码中使用sessionParams值。这是我如何设置我的一个片段:

  //设置URLRequest 
_uploadURL = new URLRequest;
_uploadURL.url = _url +? + _sessionParams;
_uploadURL.method =GET;
_uploadURL.data = _variables;
_uploadURL.contentType =multipart / form-data;

变量名是不同的(但相似),因为它是可重用类的一部分。 >

希望能帮到你。如果没有,让我知道,我会尽量提供更多的代码或解释来帮助你。


I have a flex app that uploads files to a server. The server requires authentication to be able to upload. In IE the upload works fine. However in FF and Safari, it does not upload. I have seen people all over with this same problem but no answers. Don't fail me now stackoverflowers.

解决方案

I found this question while trying to find the answer myself. The solution was rather simple.

Based on the flash player bug that others have linked, and the comments on that page, I decided to append session identifiers to my upload URL and give it a shot. It really was that easy!

To make it work, I started by adding a flashVar parameter called sessionParams. This allowed me to pass any string I want in to the flash player as my session identifier, and it will later get appended to the URL used to upload.

//sessionParams - resolves firefox upload bug
public var sessionParams:String = "";

//...

public function initApp():void{
    sessionParams = Application.application.parameters.sessionParams;
}

In my case, I'm on ColdFusion with java sessions enabled, so my sessionParams are setup like the following before being passed into the flash player:

<cfset flashVars = "sessionParams=#urlEncodedFormat('jsessionid=' & session.sessionid)#" />

Don't forget to escape special characters like =,&, etc (which I've done with urlEncodedFormat), so that they are treated as part of the value of the "sessionParams" parameter, and not breakpoints to indicate other parameters. You're embedding future-URL information in the current URL.

Then, use the sessionParams value in your upload code. Here's a snippet of how I set mine up:

// Set Up URLRequest
_uploadURL = new URLRequest;
_uploadURL.url = _url + "?" + _sessionParams;
_uploadURL.method = "GET";
_uploadURL.data = _variables;
_uploadURL.contentType = "multipart/form-data";

The variable names are different (but similar) because this is part of a reusable class.

Hopefully that helps you. If not, let me know and I'll try to provide more code or explanation to help you out.

这篇关于如何让Flex文件上传在Firefox和Safari浏览器上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆