6 Replies Latest reply on Mar 31, 2008 9:26 AM by __lucas

    FileReference: Upload never makes request on Mac

    __lucas
      I have a really strange FileReference upload bug popping up only on Mac (Flash Player build 9,0,115,0 with debugger) popping up in my app (built using Flex Builder 3 Pro).

      Works perfectly on all Windows machines. Fails only on Mac's and does not depend on browser (same results in safari and FF 2 and 3 beta).

      I have two chunks of code, one for uploading mp3's and the other for uploading images. The code for uploading mp3s does not have this problem at all. But the code for uploading the image dies silently and the request never makes it to the server.

      Has anyone run in to this type of problem before? Like i said, almost the exact same code works perfectly fine for mp3s. Just images are breaking. Some kind of weird security or headers thing going on? I have a workaround for the mean time that just opens a new window with an HTML form to upload the image if this problem pops up, but I'd like to find a long term solution so that the entire app can standalone and I can ditch the HTML form.

      Any help greatly appreciated.

      Thanks,
      Lucas
        • 1. Re: FileReference: Upload never makes request on Mac
          Arty13 Level 1
          can you post the two sets of code so we can take a closer look at it?

          I ran into FileReference bugs with Macs in the past, but it was an Adobe Player bug and had to wait for adobe to release a newer version in order for the fix.

          Art
          • 2. Re: FileReference: Upload never makes request on Mac
            __lucas Level 1
            Thanks Art. Here is the offending code for the image portion. The mp3 portion I'm afraid might be too long to digest, since its several pages (trying to match file names against title in the database, guessing track numbers, etc) :) If it'll help, i can get all of that culled together. As you can imagine, I've been pulling my hair out over this one for a few days, so its kind of a mess at this point.

            On the PHP end catching the upload, I'm already doing the echo "Complete"; mac workaround and the URL is correct.

            Thanks,
            Lucas
            • 3. Re: FileReference: Upload never makes request on Mac
              __lucas Level 1
              Sorry cant find attach code
              <code>
              /**
              * Upload an image.
              */
              public var NEW_ARTISTS_FILES:ArrayCollection = new ArrayCollection();
              public var NEW_ARTISTS_FILES_LIST:FileReferenceList = new FileReferenceList();

              // Called from a button click event
              public function browse_addArtist():void{
              NEW_ARTISTS_FILES_LIST.addEventListener(Event.SELECT, artist_selectHandler);
              var IMAGE_TYPE:FileFilter = new FileFilter("Images (*.jpg); (*.gif); (*.tiff); (*.png)" ,"*.jpg; *.gif; *.tiff; *.png");
              var ARTIST_FILE_FILTERS:Array = new Array(IMAGE_TYPE);
              NEW_ARTISTS_FILES_LIST.browse(ARTIST_FILE_FILTERS);
              }

              public function artist_selectHandler(event:Event):void{
              consoleDebug('Artist select handler called.');
              var newFile:Object = new Object();
              newFile.file = event.currentTarget.fileList[0];
              NEW_ARTISTS_FILES.addItemAt(newFile, 0);
              txt_browseSrc.text = NEW_ARTISTS_FILES.getItemAt(0).file.name;
              consoleDebug(NEW_ARTISTS_FILES.getItemAt(0).file.name);
              }

              [Bindable] public var imageUploadProgress:Number = 0;
              public function uploadPicture(id:int):void{
              imageUploadProgress = 0;
              var __file:FileReference = FileReference(NEW_ARTISTS_FILES.getItemAt(0).file);
              // PorgressEvent never gets fired on Mac
              __file.addEventListener(
              ProgressEvent.PROGRESS,
              // win_status is a modal pop up created earlier in the process
              function (event:ProgressEvent):void {
              win_status.statusProgressBar.indeterminate = false;
              win_status.statusProgressBar.setProgress(event.bytesLoaded,event.bytesTotal);
              win_status.statusProgressBar.label = "Uploading " + Math.round(event.bytesLoaded / 1024) + " kb of " + Math.round(event.bytesTotal / 1024) + " kb ";
              consoleDebug('Image upload Progress: '+(event.bytesLoaded / event.bytesTotal));
              imageUploadProgress = (event.bytesLoaded / event.bytesTotal);

              if( (event.bytesLoaded / event.bytesTotal) == 1){
              consoleInfo('Upload complete. Checking if there are more items to upload...');
              try{NEW_ARTISTS_FILES.removeItemAt(0);}catch(e:Error){}
              consoleInfo('Finished uploading artist art.');
              win_status.statusProgressBar.indeterminate = true;
              finish_statusWindow('Artist created successfully!', 'New Artist created!', 'Complete',transitionFromArtistToAlbum);
              }
              }
              );
              __file.addEventListener(SecurityErrorEvent.SECURITY_ERROR,function (event:SecurityErrorEvent):void{consoleInfo(event);});
              __file.addEventListener(HTTPStatusEvent.HTTP_STATUS,function (event:HTTPStatusEvent):void {consoleInfo(event);});
              __file.addEventListener(IOErrorEvent.IO_ERROR,function (event:IOErrorEvent):void{consoleInfo(event);});
              consoleDebug('Uploading to '+BASE_URL+'uploadImage.php');
              consoleDebug('File name is '+__file.name);
              var __request:URLRequest = new URLRequest(BASE_URL+'uploadImage.php');
              __request.method= 'POST';
              __request.data = 'FlashRequest=true&id='+id;
              __file.upload(__request, 'Image');
              }
              </code>
              • 4. Re: FileReference: Upload never makes request on Mac
                Arty13 Level 1
                lucas,

                I'm not seeing anything out of the ordinary from what I've done in the past, and it could be a bug otherwise it has to do with something with the __file or the URLRequest, the progress event wont fire unless the upload gets fired. And to me it sounds like the upload isnt firing...
                If there was a security error, you would get notified after the upload got fired, but if the upload didnt get fired you wont get any type of errors...

                The only thing I can suggest is comparing your mp3 uploader and the image uploader closer and look at all the differences.

                Sorry I couldnt be more help.

                Art
                • 5. Re: FileReference: Upload never makes request on Mac
                  __lucas Level 1
                  Hey Art,

                  Thanks anyway. Turns out its a problem in the web app related to
                  http://www.disinnovate.com/2006/10/6/flash-player-for-mac-file-upload-remoting-port-80

                  Web app wasn't set up properly to allow a port number to be appended.

                  Thanks,
                  Lucas
                  • 6. Re: FileReference: Upload never makes request on Mac
                    __lucas Level 1
                    One other thing to note here as well. On Mac when you're dealing with a small file (say less than 100K) and a moderately quick connection, you may not get any progress events. So you really should implement all of the event handlers (complete and data complete) to make sure there aren't any hiccups.

                    - Lucas