RSS LinkedIn Twitter

Error #2044: Unhandled IOErrorEvent; text=Error #2038: File I/O Error.

I started this post a few months ago while I was working on an AIR application that uploads files to a remote server (by way of an upload script).  I ran into this error, Error #2044: Unhandled IOErrorEvent; text=Error #2038: File I/O Error,  which caused me considerable grief until I discovered the simple solution.  I got the same error in an application I was working on today, and so decided to finish this post.

I looked up the problem when I first encountered it, and there seemed to be a consensus that the problem was due to using a bad URL for the location of the upload script.  That was actually the case for me today, so I was able to fix it right away.

When I encountered the problem a few months ago, you could say that it was from using a bad URL, but it was much less obvious.  I had written the upload script in ColdFusion, hosted on a CF server.  I was certain that I had the URL typed correctly because I could access it in my browser.  I discovered over an hour later that I had an authenticated session that allowed me to see it in the browser, a privilege not shared by the AIR app.

The problem was ultimately remedied by placing a special Application.cfc in the upload script’s directory that did away with the requirement for any session variables.  This particular case may have been due to a combination of the CF server’s settings and the fact that I was using AIR, and not a Flex app that might have been served from the same server as the upload script.

Tags:

7 Responses to “Error #2044: Unhandled IOErrorEvent; text=Error #2038: File I/O Error.”

  1. February 7th, 2009 at 23:05
    1

    I have the same error when i running the swfupload. Please advice the related code ti fix the problem. Please.

  2. February 7th, 2009 at 23:22
    2

    In the case where I had mistyped the URL, I simply made sure that the URL I was referencing in my application was the same as the location of the upload script on my server.

    In the other case (where I used the Application.cfc file) the ColdFusion server in question was set up with a global Application.cfc, that among other things, denied access to anyone or anything that hadn’t been authenticated. So in this case the URL was inaccessible (not mistyped). The Application.cfc I put into the upload script directory simply removed the check that was testing for a valid session. The source code for that Application.cfc isn’t anything spectacular:



  3. shafi
    December 24th, 2009 at 01:53
    3

    I am very new to flex. I want to upload the file for this I have seen the code from adobe.. what is this variable FILE_UPLOAD_URL. what is the purpose of this URL. if it is some already build script where from should I get it

    it is used in
    fileRef.upload(new URLRequest(FILE_UPLOAD_URL));

    private const
    FILE_UPLOAD_URL:String “http://172.16.1.10/esacore/Images/”;

    private function init():void {
    fileRef = new FileReference();
    fileRef.addEventListener(Event.SELECT, fileRef_select);
    fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);
    fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
    }

    private function browseAndUpload():void {
    fileRef.browse();
    message.text = “”;
    }

    private function fileRef_select(evt:Event):void {
    try {
    message.text = “size (bytes): ” + numberFormatter.format(fileRef.size);
    fileRef.upload(new URLRequest(FILE_UPLOAD_URL));
    } catch (err:Error) {
    message.text = “ERROR: zero-byte file”;
    }
    }

  4. jwd
    December 24th, 2009 at 10:31
    4

    The FILE_UPLOAD_URL is simply the URL where a script resides that will perform the file upload on the server side.

    In PHP, this script might look something like this:
    move_uploaded_file($_FILES['Filedata']['tmp_name'], "./" . $_GET['dir'] . "/".$_FILES['Filedata']['name']);

    In ColdFusion, that script might look something like this:
    <cffile action="UPLOAD" filefield="Filedata" destination="#ExpandPath('./upload/')#" nameconflict="OVERWRITE" />

    Hope that helps.

    Here are some links to documentation on the topic (for these two languages) you may find helpful:

    http://php.net/manual/en/function.move-uploaded-file.php

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-738f.html

  5. Ivan Surya
    November 13th, 2010 at 00:29
    5

    Hi John,

    Strangely I came across this same issue recently, but I’m using Flex web application.

    For some reason, my swf, which is located in the “bin” folder, is unable to find my “uploader.cfm”, which is stored in the “components/xx/xx” folder.

    I’m also sure that the URL is valid as I can access it by using a browser, but my Flex app (in FileReference’s upload() method) seems to unable to find the uploader.cfm (I pass the correct URL to the upload() method and keep on getting IO Error #2038 saying it’s a bad URL).

    Any suggestions how to fix this? I’m a newbie in ColdFusion so I’m not sure how to write the Application.cfc that allows us to remove the requirement for a session variable.

    Many thanks,

    Ivan.

  6. Steve
    December 14th, 2010 at 10:08
    6

    Thanks so much for this. I just put my upload cfm in it’s own folder with an application.cfm. Everything worked fine from there.

  7. sfg
    July 11th, 2011 at 15:09
    7

    HI, I have a similar problem with a linux server, I have tried with a lot of URL but no works, my scripts are in the folder
    var/www/assets/upload.php and I don´t know what URL put in the filereference class.
    Anyone can help me please

Leave a Comment

*