is there a possiblity to upload a file from html forms without using multipart/form-data? I'm using Servlets 2.5 so I can't use getPart method and I still want to use getParameter method to get values from fields.
- why not upload via PUT. same topic PUT with jquery : stackoverflow.com/questions/5518420/…farmer1992– farmer19922013-01-19 18:41:07 +00:00Commented Jan 19, 2013 at 18:41
- 1possible duplicate of How to upload files to server using JSP/Servlet? Please read the example that shows how to get other request parameters apart from the file.Luiggi Mendoza– Luiggi Mendoza2013-01-20 05:53:27 +00:00Commented Jan 20, 2013 at 5:53
3 Answers
The multipart/form-data encoding type is a fundamental part of the HTML file upload mechanism - see for instance the RFC where it was first standardised, particularly this section headed "File transfer with ENCTYPE=x-www-form-urlencoded".
While there are other methods of uploading files now available (e.g. backed by Flash widgets) none of these can allow you to submit part of the form in normal x-www-form-encoded format but also attach uploaded files.
Perhaps you could write a wrapper object which wraps an API which supports multipart/form-data and implements the getParameter method you want on top of it for non-file fields.