2 Replies Latest reply on Jan 16, 2008 5:09 PM by sthzg

    file upload problems

    sthzg
      Hi,

      I have a problem with a file upload (processed with PHP). In the application the user can select an image-file to upload. The first time it always throws an IOErrorEvent:
      [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035"]

      When I reopen the file open-dialog box and select the same file again though the upload works just fine. Do you have any ideas what might cause that problem?

      My testserver: Win-XP with Apache 2.0 and PHP 5.2.

      And just in case ... here's the relevant code to handle the file upload:

      fileRef = new FileReference()
      fileRef.addEventListener(Event.SELECT, fileSelectHandler);

      private function fileSelectHandler(event:Event):void {
      var request:URLRequest = new URLRequest(path + "fileupload.php");
      try {
      fileRef.upload(request, 'Filedata');
      } catch (error:Error) {
      trace("...");
      }
      }
        • 1. Re: file upload problems
          chris.huston.t10 Level 3
          I'm not sure what is causing your error, but here is some code that I use to upload files that might be of some help to you. I use PHP 5.2 with Apache 2.2.6, though I doubt the Apache version is relevant to your problem.

          private var fileRef:FileReference;

          //Select an image for upload to the server
          private function selectFile():void {
          var mediaType:FileFilter;
          mediaType = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
          fileRef = new FileReference();
          fileRef.browse([mediaType]);
          fileRef.addEventListener(Event.SELECT, uploadFile);
          }

          //Uploads the selected file via the associated PHP script
          private function uploadFile(evt:Event):void {
          var request:URLRequest = new URLRequest();
          request.url = path + "fileupload.php";
          request.method = URLRequestMethod.POST;
          fileRef.addEventListener(Event.COMPLETE, uploadComplete);
          fileRef.upload(request);
          }

          //Listenes for the complete event from the file upload.
          private function uploadComplete(evt:Event):void {
          trace('Image has been uploaded');
          }

          Vygo
          • 2. Re: file upload problems
            sthzg Level 1
            Thanks for your reply. I still get the error (after testing it for a while I found out that the error - although it does most of the time - does not always occur on every second try, sometimes it works two to three times in a row, then it fails two to three times ...). However, I do only encounter this problem on my local testserver. On the productionserver (LAMP) it works just as it should. That's why I thought it might be a WAMP issue. Tomorrow I'll try it on a different WAMP machine. Maybe it's something particular with my local settings.