我的 Flex 应用程序中有以下代码:
protected function btn_select_image_clickHandler(event:MouseEvent):void {
fileRef.addEventListener(Event.SELECT, Image_Select);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.browse(UploadFilter);
}
private function Image_Select(e:Event) : void {
var fileSize:Number = Math.round( fileRef.size / 1024 );
if ( fileSize <= 500 ) {
var request:URLRequest = new URLRequest( "http://gestor.domain.com/upload_image.php" );
try {
fileRef.upload( request );
} catch(error:Error) {
Alert.show( "Error loading image.", "Error" );
}
} else {
Alert.show( "Image higher than 500Kb.", "Warning" );
}
}
private function completeHandler(e:Event) : void {
var file:FileReference = FileReference( e.target );
Alert.show( "Data returned: "+file.data);
if ( file.data != null ) {
_filerefUploadMode = false;
fileRef.load();
}
}
php 文件仅回显在 compleHandler 触发时要显示的字符串。
事实是 file.data 只返回null而我不知道发生了什么。
我失踪了吗?