flex图片上传问题
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Metadata>
[Event("uploadComplete")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import flash.net.FileReference;
private var fileRef:FileReference;
public function get fileName():String {
return fileRef.name;
}
private function fileBrowse():void{
this.fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
var gifFilter:FileFilter = new FileFilter("GIF Images", "*.gif", "GIFF");
fileRef.browse( [gifFilter] );
}
private function selectHandler(event:Event):void {
var request:URLRequest = new URLRequest("http://localhost:8080/");
fileRef.upload(request);
}
private function completeHandler(event:Event):void {
dispatchEvent(new Event("uploadComplete"));
}
]]>
</mx:Script>
<mx:Canvas>
<mx:Button click="fileBrowse()" label="Browse"/>
</mx:Canvas>
</mx:Application>
我怀疑是URLRequest里面的url问题,可是不管怎么改都上传不了,怎么回事,请大侠解决,在线等
[解决办法]
你的路径错了, 如var request: URLRequest = new URLRequest("http://localhost:8080/GoodsMgt/uploadImage"); GoodsMgt是项目uploadImage是web.xml配置的servlet路径
[解决办法]