2009-11-19 95 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有他們的理由。