Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

17
  • Ah sorry, I was seeing request.getParts("file") and was confused x_x Commented Nov 5, 2016 at 22:02
  • With Servlet 3.0, if a MultipartConfig condition is violated (eg: maxFileSize), calling request.getParameter() returns null. Is this on purpose? What if I get some regular (text) parameters before calling getPart (and checking for an IllegalStateException)? This causes a NullPointerException to be thrown before I have a chance to check for the IllegalStateException. Commented Nov 20, 2016 at 14:34
  • @BalusC I created a post related to this, do you have an idea how I could retrieve extra infos from File API webKitDirectory. More details here stackoverflow.com/questions/45419598/… Commented Jul 31, 2017 at 23:52
  • 1
    Yeah, if someone tries to use the code in 3.0 section with tomcat 7, they might face issue in String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // MSIE fix.part similar to me Commented Sep 24, 2018 at 13:24
  • 2
    @aaa: that can happen when you converted bytes to characters by using a Reader and/or Writer for unclear reason. Do not do that. Use InputStream/OutputStream over all place during reading and writing an uploaded file without massaging bytes into characters. A PDF file is not a character based text file or so. It is a binary file. Commented Apr 1, 2021 at 10:01