flex actionscript not uploading file to PHP page H

2019-08-26 17:02发布

问题:

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:

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.