2009-11-19 94 views
0
private var fileRef:FileReference 

    private function doCreationComplete():void 
    { 
     fileRef= new FileReference();   
     fileRef.addEventListener(Event.COMPLETE, completeHandler); 
     fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress); 
     fileRef.addEventListener(Event.SELECT, doSelect); 
    } 
    public function doBrowse(event:Event):void 
    { 
     try 
     { 
      fileRef.browse(); 
     } 
     catch (error:Error) 
     { 
      trace("Unable to browse for files."); 
     }   
    }  
    public function doSelect(event:Event):void 
    { 
     txtPhoto.text = fileRef.name; 
    } 
    public function doSubmit(event:Event):void 
    { 
     var request:URLRequest = new URLRequest("http://localhost:8080/JustSms/com/contacts/serviceImpl/CSVReader"); 

     var vars:URLVariables = new URLVariables(); 

     vars.person = txtPerson.text; 

     request.data = vars; 

     fileRef.upload(request); 
    } 
    function completeHandler(event:Event):void 
    { 
     trace("uploaded"); 
    } 

    private function fileRef_progress(evt:ProgressEvent):void 
    { 
     progressBar.visible = true; 
    } 

错误#2044:未处理的IOErrorEvent :.文本=错误#2038:文件I/O错误。在flash上​​,uploadcontacts/___ TitleWindow1_creationComplete()[D:\ Flexspace \ SMS \ src \ uploadcontacts.mxml:3] 上传uploadcontacts/doCreationComplete()[D:\ Flexspace \ SMS \ src \ uploadcontacts.mxml:17] 。 events :: EventDispatcher/dispatchEventFunction()Flex中的文件上传

什么是这个错误?我怎么处理这个...是否正确的方法来请求Servltet? plz帮助我..

+0

其中是行:17指向?你用什么语言与服务器通信? – Treby 2009-11-19 05:31:32

回答

0

下载类似Fiddler或Firebug,并告诉我们什么是HTTP流量。

您还应该将错误事件侦听器添加到FileReference对象,以便您可以在错误发生时捕获这些错误。 (他们可能会出于多种原因不在你的控制之下......)。所有Flex documents都向您显示了要捕获哪些错误的示例。唯一的问题是,有时你会为一个请求得到两个错误。例如,根据我的经验,如果我得到一个HTTP_STATUS错误,我也会得到一个IO_ERROR。似乎愚蠢的我,但也许Flex/Adob​​e有他们的理由。