View Full Version : Having problem with <input type="file"..

03-25-2004, 10:04 PM

I have the following form element in my jsp page:

<form method="post" enctype="multipart/form-data" action="<%=someUrl%>">
<input type="file" name="userfile">

which allows a user to select a filename by clicking on the browse button.

In my servlet, I am trying to get the name of the file selected by the user as follows:

String sFileName = request.getParameter("userfile");

When I print out sFileName, it prints null. Does anyone have any idea or suggestion how to get this user entered filename in the servlet?

Thanks a lot!

03-29-2004, 09:16 AM
When form encoding is "multipart/form-data" which is required for upload forms, you will not be able to retrieve form data normally (using request.getParameter)

Have you heard of JspSmartUpload component (http://products.datamation.com/development/java/953919483.html)?