title: Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error
body: <p>I have a standard AIR script compiled on Flash or Flash Builder 4.5 designed to upload a file to a php server-side code. The code starts by writing the file to the users desktop, before completing the request.</p>
  
  <pre><code>import flash.net.*;
  import flash.filesystem.*
  
  //create the file
  var file:File = File.desktopDirectory;
  file = file.resolvePath("test.txt");
  var fs:FileStream = new FileStream();
  fs.open(file, FileMode.WRITE);
  //write "test" to txt file
  fs.writeUTFBytes("test");
  fs.close();
  
  //start request
  var req:URLRequest = new URLRequest();
  req.method = "POST";
  req.url = //php file
  var vars:URLVariables = new URLVariables();
  vars.a = 1;
  vars.b = 2;
  vars.c = 3
  req.data = vars;
  file.upload(req, "txt_file");
  </code></pre>
  
  <p>Now, when I upload to a php file on my own Apache test server on localhost (XAMPP), the file upload goes through without any errors. However, when I try to upload to my actual server, I get an I/O error: </p>
  
  <blockquote>
    <p>Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O
    Error.</p>
  </blockquote>
  
  <p>I have checked my max_file_size set at 2MB so that is not the issue. The URL is also correct. Looking at other sources (e.g. <a href="http://www.judahfrangipane.com/blog/2007/01/01/error-2044-unhandled-ioerrorevent-texterror-2038-file-io-error/" rel="nofollow">http://www.judahfrangipane.com/blog/2007/01/01/error-2044-unhandled-ioerrorevent-texterror-2038-file-io-error/</a>), some suggest the issue is with Apache ModSecurity, turned off by setting .htaccess for the directory to:</p>
  
  <pre><code>SecFilterEngine Off
  SecFilterScanPOST Off
  </code></pre>
  
  <p>This does not work. In fact, it makes the rest of my code designed to obtain data from the same server obsolete. I also know its not a cross-domain issue. I have also tried setting the php code to return HTTP 200. Still does not work. Some have suggested that these errors are a bit random and the actual file upload has taken place regardless of the error. So the problem could be fixed by just catching the error and ignoring it (<a href="http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/" rel="nofollow">http://dev.nuclearrooster.com/2008/04/05/uploading-with-a-filereference-from-flex-3-on-os-x/</a>). This is not an option for me as I need to track the upload progress.</p>
  
  <p>What is interesting is that this seems to be a Mac OSX issue as I have the exact script running on a Windows compiler without errors although the only stipulation is that they were made with older version of AIR. So I am not sure whether that is the case here. </p>
  
  <p>I have been banging my head against the wall for 3 days. Please help me......</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Just found that my server where the file is uploading to is returning a HTTP 301 response on the file upload request, something which again only happens on OSX on AIR and not on Windows or form data submitted via Firefox.</p>