views:

29

answers:

1

hello,

please help! I am using actionscript 3 with flex sdk 3.5 and PHP to allow a user to upload a file -that is my goal. However, when I check my server directory for the file... NOTHING is there! For some reason SOMETHING is going wrong, even though the actionscript alerts a successful upload (and I have even tried all the event listeners for uploading errors and none are triggered). I have also tested the PHP script and it uploads SUCCESSFULLY when receiving a file from another PHP page (so i'm left to believe there is nothing wrong with my PHP).

However, actionscript is NOT giving me any errors when I upload -in fact it gives me a successful event...and I know the my flex application is actually trying to send the data because when I attempt to upload a large file, it takes significantly more time to alert a "successful" event than when I upload a small file.

I feel I have debugged every aspect of this code and am now spent. pleaseeee, anyone, can you tell me whats going wrong?? or at least how I can find out whats happening? -I'm using flash bugger and I'm still getting zero errors. -I can also UPLOAD without any issues.

private var fileRef:FileReference = new FileReference();
private var flyerrequest:URLRequest = new URLRequest("http://mysite.com/sub/upload_file.php");

private function uploadFile():void{
fileRef.browse();
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
}


private function selectHandler(event:Event):void{

fileRef.upload(flyerrequest);
}

private function completeHandler(event:Event):void{
Alert.show("uploaded");
}




<?php
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./test/".$_FILES['Filedata']['name']);
?>
+1  A: 

Some idea:

  1. have you chmod the directory on your server to 777.

  2. add the EventListener of IOErrorEvent.IO_ERROR in the script to check whether there is io error.

  3. take a look and try the following example http://weblog.cahlan.com/2006/12/flex-upload-component.html and also have a look on its comments.
michael
HOLY CONOLY. it was a chmod issue! my goodness. lesson learned lol. Thanks a lot!
Rees