• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload Servlet

 
Ryan Lowe
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,
I am trying to upload a file via an HTTP <INPUT TYPE="FILE" NAME="file_part"> parameter using Servlets. I have downloaded the O'reilly packages, and gotten them to work ... but I am having trouble writing my own (learn by doing ). I have tried:
File f = new File ( request.getParameter ( "file_part" ) ); (which throws a NullPointerException, regardless of whether the field is populated).
AND too many hours of fruitless labor. Any suggestions? I can manipulate files fine, but I just can't GET the file
Thanks,
Ryan Lowe
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
Plz do a search on this forum on "file upload", go through the results, your problem would be solved by that.
hth
MB
 
Torsten Schippel
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ryan,
try a BufferedReader to read the lines posted by your form.

You should find the difference between a normal form POST and an "multipart/form-data" POST.
Then you may be able to write your own multipart parser.
Regards
Torsten
 
Ryan Lowe
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Torsten. That provided me with the direction I needed Also, Malhar ... Most of the references on JavaRanch point to the oreilly packages or other libraries, not instructions on how to do it *manually*.
Thanks Again,
R
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic