0

Iam not able to upload files in FireFox and safari but iam able to do it successfully in explorer. When i tried to debug i found out that in case of IE the upload browser is giving the entire file as eg C:\Documents and Settings\jjayashree\My Documents\price.csv but where as in FF and safari the upload widget is just giving the file name with no extension. previously code was like this if (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");
    }

i changed it as if (this.fileName != null && this.fileName.trim().length() > 0) { this.fileName = this.fileName.substring(this.fileName.lastIndexOf("\") + 1, this.fileName.length()); }

i found it working but when the same is deployed in linux iam getting an error

I also hav a doubt becos in the doPost of servlet iam using fileName.replace("\", "/");

is this the problem. . How wil mozilla encounter this fileName.replace() wil it just see and find nothing can be replced and go or wil it throw any kind of Exception

  • 1
    Duplicate of [How to get file path in firefox?](http://stackoverflow.com/questions/81180/how-to-get-the-file-path-from-html-input-form-in-firefox-3/3374408#3374408) You're making a major fundamental mistake here. – BalusC Mar 04 '11 at 13:31

1 Answers1

0

Maybe try gwtupload? It simplifies file loading to one function call, and handles all the backend for you. It's a little complicated to get working but there's a tutorial on the site on how to do it.

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

therin
  • 1,448
  • 1
  • 15
  • 27