4 Replies Latest reply on Mar 9, 2007 1:15 PM by dave cragg

    Upload File and get XML response

    __Voodoo__Child__ Level 1
      When uploading a file using FileReference's upload method, is there a way to get some information back from the server other than the 'complete' event. I need more information other than complete with no HTTP errors.

      For example, I upload a zip file, do a bit of processing on the zip (check for some information within the zip file ) then I want to send some XML back to the requesting actionscript... like the 'result' handler for HTTPService. Is this possible?

      ::server script pseudo::
      get Filedata (zip file) from post
      write Filedata to disk
      do stuff to zip file contents
      spit out some XML (this xml would be consumed by actionscript)

      I have not been able to figure out how to do this using FileReference.
        • 1. Re: Upload File and get XML response
          dave cragg Level 2
          I don't have an answer, but I need to be able to do something similar in the near future.

          Could you do it in a 2-stage process? I.e. send an httpService request when the "complete" event fires. This would probably mean maintaining some kind of "session data" on the server. But you can send other data as part of the urlRequest used by the FileReference upload. It may be possible to use that to help when processing the "follow-up" request.

          If you find a solution, please post it.
          • 2. Re: Upload File and get XML response
            __Voodoo__Child__ Level 1
            Thanks for the reply. I see what you are saying and you're right, we could definitely do it in 2 stages. It would just be really nice to do it in one step avoiding maintaining the state on the server for something simple like this.

            I can't find any hints or clues in the docs about how to do this either. So, I am wondering if it is just a limitation of Flash file uploading and if so, why is it a limitation?
            • 3. Re: Upload File and get XML response
              __Voodoo__Child__ Level 1
              Well I'm an idiot The answer was right there in the docs...

              The FileReference object will dispatch a uploadCompleteData event that you can listen for, and when it fires use the data property to extract the server's response

              _fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onUploadCompleteData);

              var mUploadURLRequest:URLRequest = new URLRequest( _uploadURL );


              private function onUploadCompleteData( e : DataEvent ) : void
              var data : Object = e.data;
              trace( ObjectUtil.toString(data) );
              • 4. Re: Upload File and get XML response
                dave cragg Level 2
                Thanks for that. I feel like an idiot too. I sometimes wonder whether the docs are animated in some way. This isn't the first time I've missed something that was staring me in the face.