1

I have a file upload component to populate a grid using the file content. I need to implement a refresh grid functionality to capture the changes in the uploaded file. The idea is to re-upload the file without manually having to browse the location. The code snippet used for uploading the file is as follows. what would be the best way to implement this?

@Override
public OutputStream receiveUpload(String filename, String encoding) {
    FileOutputStream output = null;

    try {
        logFile = File.createTempFile("test", ".log");
        output = new FileOutputStream(logFile);
    } catch (IOException e) {
        logger.error("Error in upload", e);
    }

    return output;
}
Misha
  • 37
  • 1
  • 7
  • 1
    What do you mean `without having to browse the location`? If you want to select a predefined path for a file upload, you can't. That operation runs on the user's PC (from his browser) and for security reasons he/she has to explicitly select the file (imagine predefining `c:\passwords.txt`). Further reading: [how-to-set-a-value-to-a-file-input-in-html](https://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html) and [remember-and-repopulate-file-input](https://stackoverflow.com/questions/20537696/remember-and-repopulate-file-input/) (linked from the 1st). – Morfic Jul 12 '17 at 10:57
  • My requirement is similar to having a file load upon predefined path. With your explanation I understand that it is not possible. Thanks! – Misha Jul 12 '17 at 11:45
  • You can only fulfill those requirements if the file is accesible by your server, ie. it can read it. Security concerns as @Morfic says. – Shirkam Jul 24 '17 at 12:41

0 Answers0