0 Replies Latest reply on Apr 29, 2014 8:01 AM by willgrrtt

    File Upload. Add path to database.

    willgrrtt

      I currently have fileupload working fine. I can select a file I store it in a local folder on my computer.
      I would now like to store the file in the same folder but get the file name and store that in my database.

      I have my database and table setup already.

       

      public void upload(){

        log.info("User wants to upload a file {0}", fileName);

        log.info("Saving file...");

        File file = new File(FILE_FOLDER + "/" +  fileName);

        FileOutputStream fos;

        try {

        fos = new FileOutputStream(file);

        byte[] buffer = new byte[8 * 1024];

       

        while ((fileContents.read(buffer)) > 0){

        fos.write(buffer);

        }

        fos.flush();

        fos.close();

        fillFileList();

        StatusMessages.instance().add(Severity.INFO,"You file has been saved :)");

       

        } catch (Exception e) {

        e.printStackTrace();

        }

        }