Avatar of dreamsdll
dreamsdll
 asked on

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

Hi,

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
Adobe Flash

Avatar of undefined
Last Comment
dreamsdll

8/22/2022 - Mon
blue-genie

can you show us your code.
dreamsdll

ASKER


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

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

and

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.

:(
ASKER CERTIFIED SOLUTION
blue-genie

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
dreamsdll

ASKER
You are absolutely right with the first part, my onComplete handler wont listen to move event. Any chance of hope on this point ?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
blue-genie

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.
dreamsdll

ASKER
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 ?
blue-genie

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
dreamsdll

ASKER
It is partially acceptable.