2 Replies Latest reply on Apr 26, 2007 2:09 PM by jrpruitt

    File Download

    Stew Padaso
      Here is the file download function (below) it worked fine on my windows box and when I moved it to the unix machine it quit working. I double checked the files permissions, location of the file, etc, everything looks fine. When you try to download a file via flex, it prompts to save it on your computer, after clicking on ok nothing happens. Any suggestions for troubleshooting?

      private function downloadFile(event:ResultEvent):void {
      var confirmation:String = event.result.toString();
      var file:String = data.file_name;
      var request:URLRequest = new URLRequest('upload/'+file);
      var fileRef:FileReference = new FileReference();
      fileRef.download(request);
      }
        • 1. Re: File Download
          jlingwai

          var request:URLRequest = new URLRequest();
          request.url = 'upload/'+file;
          var fileRef:FileReference = new FileReference();
          fileRef.download(request);

          I would also add listeners to help trouble shooting using the FileReference events
          • 2. Re: File Download
            jrpruitt Level 1
            The FileReference apparently needs to be defined as a GLOBAL, otherwise the download fails exactly the way you described.

            // Add THIS line near the top of the program
            private var fileRef:FileReference ;

            private function downloadFile(event:ResultEvent):void {
            var confirmation:String = event.result.toString();
            var file:String = data.file_name;
            var request:URLRequest = new URLRequest('upload/'+file);

            // change this line to use the predefined fileRef
            fileRef = new FileReference();
            fileRef.download(request);
            }