Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

flex actionscript not uploading file to PHP page HELP!

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']);
?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...