Note that there are some explanatory texts on larger screens.

plurals
  1. POFile upload with Flex 4.5 FileReference IOError #2038
    text
    copied!<p>I am using FileReference in Flex 4.5 to upload files to a Tibco web server. Below is the flex code that I wrote several months ago to handle this. At the time it worked just fine, however now it no longer seems to work and I can't figure out why. I'm pretty positive that nothing has changed with this portion of the code since I wrote it several months ago. When I try to use the function to upload a file I get the following error message: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error. URL: <a href="http://localhost:1112/CCWS/uploadFile?changeID=1325863504338&amp;fileName=out%2Etxt" rel="nofollow">http://localhost:1112/CCWS/uploadFile?changeID=1325863504338&amp;fileName=out%2Etxt</a>"]</p> <pre><code>public function uploadFile():void { var fr:FileReference = new FileReference(); fr.addEventListener(IOErrorEvent.IO_ERROR,function(event:IOErrorEvent):void{ Alert.show(event.toString()); }); fr.addEventListener(Event.SELECT, function (event:Event):void{ var uploadURL:URLRequest = new URLRequest(url + "/CCWS/uploadFile" ); var params:URLVariables = new URLVariables(); params.fileName = fr.name; params.changeID = requestIDText.text; uploadURL.data = params; fr.upload(uploadURL,"fileContent"); }); fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, function (event:DataEvent):void{ var obj:ObjectProxy = new ObjectProxy(); obj.fileName = fr.name; obj.fileID = event.data; filesDataProvider.addItem(obj); }); fr.browse(); } </code></pre> <p>In this instance, url was set to "http://localhost:1112" and the server was running on localhost as well, with an http request listener on port 1112. I know the server is working fine because it hosts other webservices from the same process and they all respond without a hitch (including a file download service). </p> <p>Using Fiddler2 to monitor the packet traffic, I determined that Flex was never sending the request to the server. I simplified my code to this to see if I could find what was going on: public function uploadFile():void { var fr:FileReference = new FileReference();</p> <pre><code> fr.addEventListener(IOErrorEvent.IO_ERROR,function(event:IOErrorEvent):void{ Alert.show(event.toString()); }); fr.addEventListener(Event.SELECT, function (event:Event):void{ var uploadURL:URLRequest = new URLRequest("http://localhost:1112/" ); var params:URLVariables = new URLVariables(); params.fileName = fr.name; params.changeID = "1325863504338"; uploadURL.data = params; fr.upload(uploadURL,"fileContent"); }); fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, function (event:DataEvent):void{ var obj:ObjectProxy = new ObjectProxy(); obj.fileName = fr.name; obj.fileID = event.data; Alert.show(obj.fileName,obj.fileID); filesDataProvider.addItem(obj); }); fr.browse(); } </code></pre> <p>When I attempt to upload a file to "http://localhost/" I get an HTTP 500 response, which makes sense because the index.html file in my apache home directory doesn't handle a file upload. But I can also see the packet information show up in Fiddler2. When I change the url back to "http://localhost:1112/" I again get the same kind of error message and no longer see a packet transaction in Fiddler2.</p> <p>I tried adding a crossdomain.xml file at <a href="http://localhost/crossdomain.xml" rel="nofollow">http://localhost/crossdomain.xml</a> just in case there might be a crossdomain issue trying to submit to port 1112 (which wouldn't make sense to me, but I tried it all the same). The file contained this: </p> <p>If anyone has any insight as to why I might be having issues I'd appreciate it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload