This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,866 Users
  • 2,269,775 Discussions
  • 7,916,823 Comments

Discussions

change upload file name with com.oreilly.servlet.MultipartRequest to handle the file upload

Hjava
Hjava Member Posts: 406
edited Oct 20, 2014 12:28PM in Java Servlet

1. when use com.oreilly.servlet.MultipartRequest to handle the file upload, can I change the upload file name .

2. how com.oreilly.servlet.MultipartReques handle file upload? do it change to byte ?

what  different?  if I use the following method?

   File uploadedFile = (File) mp.getFile("filename");
               FileOutputStream fos = new FileOutputStream(filename);
                byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
               fos.write(data);
             fos.close();

Answers

  • Hjava
    Hjava Member Posts: 406

    My questions are

    1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the

    file direction.

    MultipartRequest multi = 
            new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
    

    why some example still use FileOutputStream?

    outs = new FileOutputStream(UPLOADDIR+fileName);  
        filePart.writeTo(outs);  
       outs.flush();  
      outs.close();
    


    2) can I rename the file name when I use oreilly package?

This discussion has been closed.