-->

Flex 4 FileReference Issues With Firefox

2019-08-09 07:36发布

问题:

I'm trying to perform a file upload using a FileReference from a Flex app running in Firefox 4. However when I attempt to call the upload() method, the Filereference throws an IOError with the following

Error #2038: File I/O Error. URL: http://localhost:8080/admin/upload

If I don't explicitly add a listener for the IOErrorEvent, then I get a Flash player popup stating

SecurityError: Error #2000: No active security context.

The request doens't even hit my server (I can verify by placing breakpoints in the Java code and watching the HTTP Requests that go out using HTTPFox), so it seems to me that this is a client side issue (right?). I've done some searching for the problem on google and the suggestions included wrapping the upload() call in a timeout/callLater, and attempting to attach the sessionId to the request (since Firefox creates a new thread for the upload and doesn't attach the proper cookies). Neither of these approaches has worked for me.

I don't experience this problem with Internet Explorer, only Firefox.

Has anyone encountered this before? Any suggestions? Thanks for any help.

EDIT: Should mention that the SWF and the URL being requested are on the same server (localhost:8080).

回答1:

From the docs for FileReference:

For content running in Flash Player or for content running in Adobe AIR outside of the application security sandbox, uploading and downloading operations can access files only within its own domain and within any domains that a URL policy file specifies. Put a policy file on the file server if the content initiating the upload or download doesn't come from the same domain as the file server.

Also - is this running as release or in the debugger? Sometimes the behavior for server access is quite different.



回答2:

Fairly normal security sandbox issue (not prevalent to Firefox, but to Flash Player).

You just need a crossdomain file on the root of your webserver.