0 Replies Latest reply on Nov 7, 2008 9:35 AM by flexchief

    Upload to server error

    flexchief Level 1
      Hey,

      I am trying to upload a local file to a location on a server but I keep getting an Error #2044: Unhandled IOErrorEvent text=Error #2038:File I/O Error. After doing some searching around I found out that this error occurs because the path to my Perl script on the server is apparently wrong but I know for a fact that it's not!

      Can anyone please please please help me out?

      Here is my code:

      Uploader.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="startApplication();">
      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;

      private var fileRef:FileReference = new FileReference();

      private function startApplication():void
      {
      fileRef.browse();
      fileRef.addEventListener(Event.SELECT,selectHandler);
      //fileRef.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
      fileRef.addEventListener(ProgressEvent.PROGRESS,progressHandler);
      }

      private function selectHandler(event:Event):void
      {
      var thisFileRef:FileReference = FileReference(event.target);
      var uploadURL:URLRequest = new URLRequest(" http://www.touchhits.com/php/fileUpload.pl");
      thisFileRef.upload(uploadURL);
      }

      private function errorHandler(event:IOError):void
      {
      trace(event.text);
      Alert.show("Sorry something is wrong on the server side", "IO Error");
      }

      private function progressHandler(event:ProgressEvent):void
      {
      trace(event.bytesLoaded+" out of "+event.bytesTotal+" have been uploaded");
      bytesLoaded.text = "Bytes Loaded: " + event.bytesLoaded + " / " + event.bytesTotal + " uploaded...";
      }
      ]]>
      </mx:Script>
      <mx:Label x="10" y="282" text="Bytes Loaded: " width="422" id="bytesLoaded" color="#F7031A" fontWeight="bold" fontSize="17"/>
      </mx:WindowedApplication>



      fileUpload.pl

      # $dataFile is the HTTP POST variable that houses the uploaded file data
      my($buffer,$fileData);
      while(my $bytesRead = read($dataFile,$buffer,1024)) {
      $fileData.=$buffer;
      }
      # $fileData now contains the full uploaded file data


      Many Thanks
      Adam
      Flexchief