0 Replies Latest reply on Mar 19, 2008 6:42 AM by RobbieDL

    Uploading a file with AIR

    RobbieDL
      Been trying to get successfully upload a file from an AIR application to a web server, but I'm baffled as to why it's not working.

      "files" is an array that contains the path to the MP3 files that are looking to be uploaded. I've used trace to make sure they're being passed successfully to each function that uses them, and they are. Each function gets called fine, and no errors appear while the application is running, yet the files aren't uploading. I'm 99% positive it's not my PHP file that deals with the files the AIR application is sending.

      Anyone able to shed a little light on the matter? Any help would be much appreciated. Thanks.

      function uploadNext() {
      if (files.length > 0) {
      currentFile = files.pop();
      uploadFile(currentFile);
      } else {
      document.getElementById('progress').innerHTML = "MP3 player synced successfully"; } }

      function uploadFile(file) {
      var uFile = new air.File(file);
      var urlRequest = new air.URLRequest(url);
      urlRequest.method = air.URLRequestMethod.POST;
      uFile.addEventListener(air.ProgressEvent.PROGRESS, uploadProgress);
      uFile.addEventListener(air.Event.COMPLETE, uploadComplete);
      uFile.upload(urlRequest, "uploadfile"); }

      function uploadProgress(event) {
      document.getElementById('progress').innerHTML = "Uploading ..."; }

      function uploadComplete(event) {
      document.getElementById('progress').innerHTML = "Upload complete";
      uploadNext(); }