Solved

Uploading images & Image manipulation

Posted on 2004-10-14
6
206 Views
Last Modified: 2010-04-01
Hi everyone

What I am trying to do is this:

I want to have a JSP where the user browses for an image, and then clicks a submit button, I then want the selected image to be uploaded and stored...

My questions are:

1 - Can the image be stored in a MySQL database or does it have to be uploaded to a directory

2 - Is there a way to manipulate the image and make thumbnails etc in a Servlet?

3 - Is there a java API for doing things like this (if yes any chance of a url)?

Many thanks

Kris


0
Comment
Question by:KrisM82
[X]
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
  • 4
  • 2
6 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12317925
1) I would store the image in a directory.  It makes it easier to show the image to the user (via an IMG html tag), and makes it easier to backup your data (as your database doesn't contain loads of BLOB fields)
2) Yeah, sure...  Load the image in to a BufferedImage, call getScaledInstance, and write the image back out again using the JPG compression routines (http://javaalmanac.com/egs/javax.imageio/BasicImageRead.html and http://javaalmanac.com/egs/javax.imageio/JpegWrite.html)
3) See 2  ;-)

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12317932
Oh, and http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html for the "making it smaller" bit ;-)
0
 
LVL 35

Accepted Solution

by:
TimYates earned 20 total points
ID: 12318011
Oh yeah -- hehe, what a lot of typing for 20 points ;-)

When you upload an image, I would use File.getTempFile to give the file a temoprary name (that is unique to your images directory), and then store this name in the database (instead of the image itself), along with the original name of the image -- then you won't get problems with 2 people uploading an image with the same name...

Otherwise, you will get problems with user A uploading "new.gif" and user B uploading "new.gif", as one will overwrite the other...

Tim
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KrisM82
ID: 12351816
Cool thanks for the help exactly what I was looking for :0)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12355468
Good luck! :-)

Tim
0
 

Author Comment

by:KrisM82
ID: 12380282
Having a few problems with this still, any chance you could give me a hand if i post the source code?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Gain an elementary understanding of Blockchain technology.
Here's how to start interacting with our community through Post.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 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