I ran into a very difficult issue trying to get upload files using FileReference and URLRequest. File upload was working fine in Internet Explorer, but nothing would work in Firefox. I tried tracing out the request using LiveHTTPHeaders for Firefox, but I couldn’t even see any of the request data. With some help from my co-worker we determined that Firefox was not sending the session with the file upload and was producing a login error. On IE the session cookie is picked up and the upload request uses the authenticated session, no login error.
Firefox apparently uses another instance of the browser window to dispatch the uploaded file, this window does not have the session. I searched for some possible answer and it seems you need to ask the correction combination of questions to find the solution. The Flex documentation seems to hint at part of the issue, but nothing direct enough.
The FileReference and FileReferenceList classes also do not provide methods for authentication. With servers that require authentication, you can download files with the FlashÂ® Player browser plug-in, but uploading (on all players) and downloading (on the stand-alone or external player) fails. Listen for FileReference events to determine whether operations complete successfully and to handle errors.
So we know that authentication is not being passed along, so what can we do about it. Searching for information related to URLRequest and sessionid revealed a good Flexcoders post on the same issue. You need to add the session to the URLRequest (in our case we added the jsessionid for TomCat):
var request:URLRequest = new URL Request("http://www.[your url].com" + ";jsessionid=" _yoursessionid);
This was a bugger of a problem to solve and not an easy one to track down. Our first reaction to the problem was that it was the JSP page or missing form data within Flex. Then of course people start point figures at Flex in general as not having the ability to do simple form posts or upload. It only appears if you are handling authentication when you upload files to the server. I have read several post about the issue with uploading files with IE that work, but that fall down with other browsers. Unfortunately, the information is not covered well by Flex documentation. Thank goodness for Flexcoders, they have saved me a lot of grief. However, not knowing this was a problem with authentication, I spent a lot of valuable time wrestling with the issue.