« Thanks to Adobe ZMZ team | Main | Camera.getCamera (name) doesn't work in Adobe Flash Player 9 beta »
June 09, 2006
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:
response.getWriter().println("");
response.getWriter().flush();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.
Posted by Abdul Qabiz at June 9, 2006 09:46 PM
Comments
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.
thanks
Posted by: hulja at June 13, 2006 08:31 AM
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.
Posted by: hulja at June 13, 2006 08:36 AM
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?
Posted by: Andy at June 15, 2006 11:24 PM
The echo(" ") worked for me too... pretty frustrating trying to figure this out though. I should resort to Googling quicker than I do ;)
Posted by: Buck at June 19, 2006 03:53 AM
In PHP, echo ""; still did not work for me, but echo "1"; did work.
Thank you for figuring this out!!
Posted by: stoph at July 20, 2006 10:35 PM
Hi,
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 ("");
flush();
Posted by: Michael at August 7, 2006 07:56 PM
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 {
bestand.upload("upload.php);
}
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...
Posted by: Lars at August 30, 2006 04:27 AM
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";
Posted by: Charlie at October 16, 2006 09:22 PM
hello, i've tried everything mentioned and I still can't get file uploads to work, has anyone come across any other fixes?
thanks.
Posted by: Mark Huot at January 5, 2007 03:39 AM
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?
Posted by: franklin at January 10, 2007 01:28 AM
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
weird!
Posted by: Gil Barbara at January 23, 2007 12:16 PM
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.
Posted by: Casey at January 28, 2007 02:33 AM
You are a life saver. This bug has been bugging me for hours.
Posted by: Dave at March 15, 2007 09:18 PM
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,
Posted by: Jakob at April 2, 2007 03:16 PM
Thanks
It really worked for me.
All I did was to put in Java Servlet.
response.getWriter().println(" ");
response.getWriter().flush();
hats off to you all..
Posted by: Deepak Joshi at July 25, 2007 06:06 PM
ooooo Thank you mann........
My Servlet was useless without these two golden lines....
response.getWriter().println(" ");
response.getWriter().flush();
Posted by: gurmeet at July 25, 2007 06:19 PM
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.
Posted by: Evan at February 9, 2008 11:05 AM
YEEESSSSSS
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...
Posted by: Rodolfo at April 12, 2008 01:42 AM
Thanks, Abdul :) You just saved me a lot of head scratching.
Posted by: Aral Balkan at April 28, 2008 09:33 PM
The final solution is that the server script responds '&bError=0&'
in PHP could it be
die('&bError=0&');
echo '&bError=0&'; exit;
etc.
Posted by: rodrigopoloDOTcom at June 28, 2008 02:57 PM