Upload Image into Oracle Database using JSP

Posted on 2004-08-23
Medium Priority
Last Modified: 2008-03-06
Hi, I would like to upload different type of images from the server (C:\) and save it to the database. Anyone can give me sample codes or advise me? Thanks!
Question by:mwcmp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 35

Expert Comment

ID: 11868439
>  Hi, I would like to upload different type of images from the server

Upload from the server?

I guess you mean you want people to be able to select an image on their client machine, then upload it into the oracle database?

Ok, for the uploading, you will need this:


There are examples in the download on how to use it to upload files (through the <input type="file"> html tag)

Then, for storing the images in the database, you will need to use a BLOB field:


HOWEVER!!!  I can recommend NOT doing this, and storing the image on the server's harddisk, and just placing a the file location in the database.  This has the advantage that the database will stay smaller, you will not have to extract the image and work out a file name for it to display it in your webapplication, and you will be able to backup all of the images and databse quicker.  It will also be easier to debug, and extend at a later date.

I'd basically store the images inside a folder accessable to your webapplication, then store the relative path to those images in the database as a standard VARCHAR field...


Author Comment

ID: 11879780
I'd basically store the images inside a folder accessable to your webapplication, then store the relative path to those images in the database as a standard VARCHAR field...

I get your point, but can you show me some concrete examples to show me? Thanks!
LVL 35

Expert Comment

ID: 11879811
Ok, use the FileUpload library I gave you in the first link...  There are examples in there to show you how it works...

Then, if your webapp is inside:


Save the uploaded image file to


Giving it a filename by using File.createTempFile (so that you don't have problems with 3 people uploading a file with the same name)

Then, store into the database "/uploads/fil019101.gif" (assuming "fil019101.gif" is the name the createTempFile returned)

Then, in your webapplication, to point to the image, and display it, you can simply put this string into a <img src="XXX"> tag (at the XXX location, and it will display in the browser...

You can also store the original filename in the database, so people can see what it was called, and not your temporary file name :-)

Hope this is what you meant :-)


Author Comment

ID: 11902883

What should I download? I don't understand how it works!
LVL 35

Accepted Solution

TimYates earned 2000 total points
ID: 11902975

Then you can add the


to your


directory (in your webapplication in Tomcat)

And this document goes through how to use it :-)


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question