簡體   English   中英

Firefox中的文件上傳

[英]File Upload in fire fox

Iam無法在FireFox和safari中上傳文件,但iam能夠在資源管理器中成功完成此操作。 當我嘗試調試時,我發現在IE的情況下,上載瀏覽器會給出整個文件,例如C:\\ Documents and Settings \\ jjayashree \\ My Documents \\ price.csv,但在FF和safari中,上載小部件只是給出沒有擴展名的文件名。 如果((fileName.contains(“ \\”))){index = 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()。length()> 0){this.fileName = this.fileName.substring(this.fileName.lastIndexOf(“ \\”)+ 1 ,this.fileName.length()); }

我發現它可以正常工作,但是在linux上部署相同的軟件時卻出現錯誤

我還使用fileName.replace(“ \\”,“ /”);在servlet iam的doPost中有一個疑問。

這是問題嗎 Mozilla會如何遇到此fileName.replace(),它只會看到並發現什么都不會被替換,或者它將拋出任何異常

也許嘗試gwtupload? 它簡化了一個函數調用的文件加載,並為您處理所有后端。 開始工作有點復雜,但是該網站上有一個教程。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM