Workaround: FileReference onComplete is not fired on Mac OS

FileReference‘s onComplete event is not fired on Mac version of Adobe Flash Player 8.
We faced similar problem and found the workaround, thanks to comment by Bob on Nirav’s blog.
There is simple workaround, you need to sent empty response from upload server-side script. In php, you would just do echo (""); after file-upload code. In ASP, you can do Response.Write (""). In Java servlet, you can do:


That’s all, now onComplete event should trigger on Mac’s Adobe Flash Player 8.
I am posting this with a specific subject line, so that developers can easily find by doing Google search.
Thanks to Bob and Nirav.

  • hulja

    unfortunatly, this doesn’t seem to work for me. could you post an example? here’s what i’m using in my php:
    move_uploaded_file($_FILES[‘Filedata’][‘tmp_name’], “./photos/”.$_FILES[‘Filedata’][‘name’]);
    echo “”;
    and still the same problem: works fine on any browser on my PC. on my mac, it’s uploading the file, but not triggering the onComplete statement.

  • hulja

    i put a space in the echo statement, like this:
    echo ” “;
    and it works now. excellent.
    thanks for finding this and posting a solution. i’ve tried everything, from file permissions, to optimizing my AS… and the solution is as simple as this.

  • I implemented the “nothing” echo and all of our Mac people are still not getting that onComplete event to fire. I get some to work OK by adding a timeout in the onProgress event. In the onProgress event, when the bytes loaded equals the bytes total, I fire up a timer that “hand fires” the custom onComplete function. I set the onComplete event to fire that same function, as well. The code looks something like this:

    var uploadCompleteTimer:Number = -1;
    function uploadOnComplete( file:FileReference ):Void {
    clearInterval( uploadCompleteTimer );
    // DO WHAT YOU GOTTA DO for onComplete...
    listenerUpload.onProgress = function( file:FileReference, bytesLoaded:Number, bytesTotal:Number ):Void {
    if( bytesLoaded == bytesTotal )
    uploadCompleteTimer = setInterval( function () {
    uploadOnComplete( file );
    }, 5000 );
    listenerUpload.onComplete = uploadOnComplete;

    That makes it work SOMETIMES. We’re still getting hit and miss uploads on Macs. It is very definitely a Mac Flash player bug, IMHO. I’ve been able to get uploads to work more often in Firefox on a Mac, than on Safari.

    The files are not even making it to the server, sometimes. Does anyone have a better workaround?

  • The echo(” “) worked for me too… pretty frustrating trying to figure this out though. I should resort to Googling quicker than I do 😉

  • In PHP, echo “”; still did not work for me, but echo “1”; did work.
    Thank you for figuring this out!!

  • Michael

    Thanks, this solved problem – I tried with Flash 9 as well – it seems like it is still not fixed there!
    An maybe something else: I have tested my flash on several server – on some the flash worked on mac on some not – with the workaround on all.
    I had to use for php:
    echo (“”);

  • Lars

    It isn’t only a mac problem. I use windows XP with flash 8.
    I can’t get the onComplete to fire when I want to do the following. If i get an IOerror or so, i want to automattically retry the file.
    So I do this:

    luisteraar.onHTTPError = function(bestand:FileReference):Void {



    This will trigger the onProgress event and the PHP script moves the file to the correct place. But is doesn’t fire a onComplete!! I tried the MAC workarounds but is doesn’t work…

  • Charlie

    I had the same issue – FileReference upload onComplete wasn’t being triggered with Flash 9 on a Mac.
    For some reason the fix above didn’t work – printing a string at the end of the upload.php script did tho…
    echo “&error=0”;

  • hello, i’ve tried everything mentioned and I still can’t get file uploads to work, has anyone come across any other fixes?

  • franklin

    totally different bug…
    Filereference on MAC gives me an I/O error if there are spaces in the file name.
    Anyone else run into this one?

  • Gil Barbara

    onComplete used to work on Mac without this hack in my old server.
    dual xeon, rhel4, ensim 4.1
    but stop on my new server, so I need to use this workaround..
    dual woodcrest, rhel 4, ensim X

  • Casey

    I had this same problem with Flash player 9 on a Mac while uploading over an SSL connection on a Drupal 5 powered site (PHP 5.2). I found that adding print “”; seemed to fire the onComplete event handler just fine.

  • Dave

    You are a life saver. This bug has been bugging me for hours.

  • Jakob

    Thanks for sharing this problem.
    Scratched my head for a couple of hours earlier this morning.
    My script didn’t go for the echo ” “; But echo “1”; worked fine,

  • Deepak Joshi

    It really worked for me.
    All I did was to put in Java Servlet.
    response.getWriter().println(” “);
    hats off to you all..

  • gurmeet

    ooooo Thank you mann……..
    My Servlet was useless without these two golden lines….
    response.getWriter().println(” “);

  • Evan

    It’s been a while I know, but I just wanted to say thanks for this. Solved my problem, and saved me hours of stress.
    Thanks so much.

  • Rodolfo

    thanks, man!
    Evan said: “saved me hours of stress”
    Me too!!!!!
    the echo ” ” has done it
    i’m running Leopard, in Safari it does not report the progress, but the onComplete is fired ok. On Firefox 3 beta 5 it is reporting the progress and firing the oncomplete…

  • Thanks, Abdul :) You just saved me a lot of head scratching.

  • The final solution is that the server script responds ‘&bError=0&’
    in PHP could it be
    echo ‘&bError=0&’; exit;

  • Adriana


  • Only Aral’s trick worked for me (PHP):
    And even so it takes between 0.5 to 1 second to actually fire up the event.
    It’s awesome that after so many time this is not in the reference itself…
    Thanks a lot for sharing

  • Excellent fix, thanks for posting.
    However, this behavior doesn’t seem like a bug (but I know, it is a bug). The fact that our scripts should tell flash that the upload actually worked seems like a smart thing to do.
    In fixing this, I would find it a plus if Adobe required that some response was written that could be checked, as this would make our applications that rely on Flash file uploads more flexible if an error did occur during upload.

  • sunny

    Thanks a lot for this post…echo ” “(space in there) worked for me. :)

  • AWESOME, this worked perfectly!
    echo ” “;

  • I too would like to thank you for this post. it was the first one i found because of the title, and it solved the problem straight away… hazzah!

  • vishal

    echo “1”; work perfectly…
    you saved my job!!!!
    thanks a lot…. :)

  • What about in ColdFusion?

  • Aaron Christopher

    Thank you very much! This worked perfectly for me… just put echo(“1”); after your upload script, and that should cause the onComplete handler to fire on macs.
    Thanks again!

  • Well I did all those listed above but still i could not make it to work on mac. here’s my upload script:
    foreach ($_FILES as $fieldName => $file) {
    $uploadFileName = $file[‘name’];
    $secret_test = $secret_test . $uploadFileName;
    $content1 = str_replace(” “, “_”,$uploadFileName);
    $content = ‘_’.$content1;
    where do i place my echo here?
    BTW its a multi image upload also. Any information or correction on my code would be helpful. Thanks. 😀

  • philmill

    echo (“”);
    worked for my legacy PHP image uploader.

  • bartman

    Thank you so much,
    I spent hours finding this bug, concluding it could be solved with a simple echo “”;
    it makes you feel so stupid.
    But thanx alot.
    However in php4 the oncomplete event was triggered automaticcaly.

  • Thanks… this work!

  • The latest flash player fixed the issue for us.

  • Jorge

    Muchas gracias desde España una gran solución, estaba loco con el tema

  • Archana

    I am using Flash FileUpload control for .jpeg file and for .mp3 file. In backend, I am using .NET (HttpPostedFile). After uploading file, .NET save this file and write the last statement HttpContext.Current.Response.Write(“true”). mp3 files works perfectly. But for .jpeg file, file saves on the server, but not executing UploadComplete event of Flash. This happens only on MAC OS safari browser. On other OS, both the controls works perfectly. Please help me for MAC.

  • Naeem

    Can any one tell me how we can increase timeout time. when upload larger file on server. As I am uploading zip files on servers and server have to unzip and then sends response to client. but when file size is large it takes more then 15 secs. On client side i am unable to catch DataEvent.UPLOAD_COMPLETE_DATA event. It only catching Event.COMPLETE, fileRef_complete. how we can increase timeout. I am using OS WindowsXP with firefox as well as with IE. Its behavior is same on FF and IE. For small files it is working fine.

    • I hope, you figured it out. I just saw this comment, sorry couldn’t be of help when you need it.