Link to home
Start Free TrialLog in
Avatar of dreamsdll

asked on

AS2.0 fileupload oncomplete fires before actual file move at server


When i try to upload large files - say of at least 2mb - the system shows a weird problem. The onComplete event gets fired every time but with large files it gets fired before the file is moved to path at server. server side script is php.  how can we assure the onComplete is fired only after actual image move is completed at server side ? any other suggestions ?

any input will be greatly appreciated... thanks
Avatar of blue-genie
Flag of South Africa image

can you show us your code.
Avatar of dreamsdll


at flash side we use just the common upload syntax with oncomplete listener

fref.upload(__updUrl + "&fileName=" + list[i] + "&orderno=" + __sequenceNo);


listener.onComplete = function(file:FileReference):Void  {
  // does the redirection

at php side its somthing similer to this :

if ($_FILES['Filedata']['name']) {
$uploadDir = SITE_PATH."/modules/album/tempUpload/";
move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadDir . basename($_FILES['Filedata']['name']));

This works very fine with small files. But files with bigger size like 2MB+ the onComplete event gets fired just after the file post complete but before the moving finished. so in redirected page image load gives a 404 error. if we refresh the same page after a few seconds it will load.

Avatar of blue-genie
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are absolutely right with the first part, my onComplete handler wont listen to move event. Any chance of hope on this point ?
um off the top of my head, have the php set a variable to done (in the php).

have a function in the php that returns that value.
use a timer in the flash to call that function every x seconds.
once it gets a true value stop and remove that timer..

will work but I don't know if that's the best way of doing it.
Thanks a lot genie in blue... we have thought about this solution but wont it cause serious performance issues with multi file uploader - say 20-50 files at a time. :(

Any other thoughts ?
try posting in the php section.
i know about connecting from flash to php but i don't know the other way around.

research something called bulkupload - i read about it on one of the posts, but have no idea what it is.

but at the end of the day if you're uploading quite a few files that are large you'll have issues me thinks.

good luck.
It is partially acceptable.