File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Issues with uploading files and simple plain fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Issues with uploading files and simple plain fields" Watch "Issues with uploading files and simple plain fields" New topic
Author

Issues with uploading files and simple plain fields

Led Estonilo
Ranch Hand

Joined: Jan 06, 2009
Posts: 36
hi. well Ive been successful in uploading files into the server now my question is

what if I have other fields on the form? uhmmm like plain fields (text radio button etc) how can i read the parameters from the request which handles the file upload tag?

<input name="upfile" type="file">
<input name="somerad" type ="radio">
<input name="sometext" type="text">
Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
go to apache website and search commons file upload

Apache commons File upload

it helps you in differentiating between formdata and multipart data.

there you will find the answer to your question... give is a try


Rituraj Jain
Led Estonilo
Ranch Hand

Joined: Jan 06, 2009
Posts: 36
thats odd, ive read that site (I did learn how to upload files from there) but i don not remember reading info on differentiating between formdata and multipart data.
Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
i think buddy you forgot to click the User Guide on the very page i refered earlier visit this link and you will find there how to differenciate between formdata and the fileData that is comming through request....
Led Estonilo
Ranch Hand

Joined: Jan 06, 2009
Posts: 36
ohh this?

"Each file item has a number of properties that might be of interest for your application. For example, every item has a name and a content type, and can provide an InputStream to access its data. On the other hand, you may need to process items differently, depending upon whether the item is a regular form field - that is, the data came from an ordinary text box or similar HTML field - or an uploaded file. The FileItem interface provides the methods to make such a determination, and to access the data in the most appropriate manner. "

hmmm so i think I need to do research for this.
Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
don't be so fast buddy. first you just read the whole page you get answers to all of your questions. be sure to read the examples given on that very page...
Led Estonilo
Ranch Hand

Joined: Jan 06, 2009
Posts: 36
ohh yes! found it. thank you for your patience and not answering me directly. it forced me too look for it on my own.

maybe I was drunk or something when reading the users guide. thank you.
Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
Your Welcome Led.
Led Estonilo
Ranch Hand

Joined: Jan 06, 2009
Posts: 36
well i had to do additional research for it to work. but for anybody interested how to do it, Ive put a little sample code from my research





Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
hi Led,

what exactly is your problem in this code.........i am not getting it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues with uploading files and simple plain fields
 
Similar Threads
How to upload only image file
how show values in jsp from getting database
request.getParameter() returning null
File Upload
Multiple files upload using struts