Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

uploadingfile  RSS feed

 
santhoshkumar samala
Ranch Hand
Posts: 156
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one tell how to upload a file in java
into web server
thanks in advance
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The FileUploadBean is a pretty standard concept:
http://www.onjava.com/pub/a/onjava/2001/04/05/upload.html
http://www.akadia.com/download/soug/tomcat/html/file_upload_bean_java.html
One of the main things you have to remember is that on your webpage with the form, you need to specify the appropriate encoding type in the form tag:

Also, instead of an input type of text on the page, you'll need a file input:

Then, remember this--if you do use something like a FileUploadBean, then your request parameters will not be accessible in the same way--they'll be stripped out by your FileUploadBean class, and you'll get them from it. In other words, you'll get both the file and any other text parameters from the bean.
Hope that helps!
God bless,
Stephen
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!