![]() |
|
|
|||||||
![]() |
HTML - HTML File Upload using enctype=multipart/form-data in form? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Should we use enctype=multipart/form-data in the form, I know it is recommended
if the form has <input type="file">. My form has <input type="file"> and other html controls. I tried the following, form.html ========= <FORM NAME="InputForm" ACTION="test.jsp" METHOD="POST" enctype=multipart/form-data> <P><input type=text name="name" size=80> <P><input type=file name="filename" size=80> <P><input type="submit" value="Upload File Test"> </FORM> test.jsp ========= <p><%= "filename = " + request.getParameter("filename") %> <p><%= "name = " + request.getParameter("name") %> It will output filename = null name = null I don't understand why, but if i remove enctype=multipart/form-data in the form, then I am able to get the data. Please advise. Thanks!! Matt |
|
|
|
|
#2 |
|
Posts: n/a
|
Matt wrote:
> Should we use enctype=multipart/form-data in the form, I know it is > recommended if the form has <input type="file">. If you have file inputs - yes. > form.html > ========= > <FORM NAME="InputForm" ACTION="test.jsp" METHOD="POST" > enctype=multipart/form-data> Try the validator. I'm pretty sure that you need to quote attribute values which include "/" characters. > <P><input type=file name="filename" size=80> > <p><%= "filename = " + request.getParameter("filename") %> File inputs upload files, not file names. NULL is probably what happens when you implicitly cast request.getParameter("filename") to a string (when its a file). You'd probably be better finding a Java group to ask this type of question. -- David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/> Home is where the ~/.bashrc is |
|