2011-03-04 80 views
0

蔭無法在Firefox中上傳文件和Safari,但亞姆能夠成功地做到這一點在資源管理器中。 當我試圖調試我發現,在IE瀏覽器的情況下,上載瀏覽器是給整個文件作爲例如C:\ Documents和Settings \ jjayashree \我的文檔\ price.csv 但如果在FF和Safari瀏覽器上傳控件只是給文件名稱沒有擴展名。 先前代碼是這樣 如果(fileName.contains( 「\」)){ 指數= fileName.lastIndexOf( 「\」); }文件上傳在火狐狸

if (this.fileName != null && this.fileName.trim().length() > 0 && index >= 0) { 
     this.fileName = this.fileName.substring(index + 1, this.fileName.length()); 
    int dotPosition = fileName.lastIndexOf('.'); 
     String extension = fileName.substring(dotPosition + 1, fileName.length()); 
     try { 

      if (profileType.equalsIgnoreCase("sampleProfile")) { 
       if (extension.equalsIgnoreCase("csv")) { 
        //fileNameTextBox.setText(this.fileName); 
        this.form.submit(); 
       } else { 
        new CustomDialogBox(Nexus.INFO_MESSAGE, MessageConstants.SPECIFY_FILE_NAME_MSG).show(); 
       } 
      } 
    } catch (Exception e) { 
      Window.alert("SPECIFY_VALID_FILE_NAME_MSG"); 
     } 
    } else { 
      Window.alert("SPECIFY_A_FILE_MSG"); 
    } 

我改變它作爲 如果(this.fileName!= NULL & & this.fileName.trim()。長度()> 0){ this.fileName = this.fileName.substring( this.fileName.lastIndexOf(「\」)+ 1,this.fileName.length()); }

我找到了工作,但在相同的部署在Linux IAM收到錯誤

我也使用fileName.replace(「\」甲肝在servlet的IAM的doPost方法無疑becos,「/」 );

就是這個問題。 。如何WIL Mozilla的遭遇此fileName.replace()西港島線,它只是看,發現沒有什麼可以replced去或西港島線扔任何異常

+1

複製的[如何獲得在Firefox的文件路徑?](http://stackoverflow.com/questions/81180/how-to-get-the-file-path-from-html-input -form-in-firefox-3/3374408#3374408)你在這裏犯了一個主要的根本錯誤。 – BalusC 2011-03-04 13:31:02

回答

0

的也許嘗試gwtupload?它簡化了文件加載到一個函數調用,併爲您處理所有後端。工作起來有點複雜,但網站上有關於如何操作的教程。

http://code.google.com/p/gwtupload/