File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Uploading a Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading a Image" Watch "Uploading a Image" New topic
Author

Uploading a Image

Anchal Bhargava
Greenhorn

Joined: Jul 22, 2012
Posts: 6
How Can I upload a Image From a jsp page and Store it into Database
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Welcome to CodeRanch!

There are three parts to your question:
1) How to upload an image - look at the apache commons file upload library
2) Do you want to store the file in the database or on the file system with the database pointing to it.
3) How to store the file/reference in the database - read about JDBC and BLOBs

Note that most of this is done in a servlet or helper class rather than a JSP. JSPs are just for presentation.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Please read the JspFaq prior to posting.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anchal Bhargava
Greenhorn

Joined: Jul 22, 2012
Posts: 6
Thanks for your reply, I know that jsp is for presentation I mean that I have created a form in jsp and want to upload a image not reference, the actual image in Database
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It still isn't clear to me what you are asking. Let me post this answer and see if it belongs to your question:

The form in the HTML which your JSP generates should have enctype="multipart/form-data" and method="post". In addition it should contain an <input> element with type="file".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Did you read the JspFaq?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uploading a Image