• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading Image from jsp to database via servlet

 
Soumya Bardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to upload a image from the client browser to the database of my web app.I am using <input type="file" name="img"> tag in my jsp to get the file location.Then via my controller servlet i want to upload the image to database.Well i guess for security reasons browser will not give me the actual path of the file on client machine.Is it possible to upload an image in such a way?If yes what will be the servlet code?If no what is the best alternative?
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser sends the file we upload as a stream to the server, so you don't need the location of the file on the client machine. You can use Apache Commons File Upload library for your work. General instructions of how to use it are given here...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is also a JSP FAQ in this subject.
 
Soumya Bardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Ankit Garg ,
Thanks for your reply.Now my app is perfectly uploading files.Thanks Again...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic