?
Solved

load an image

Posted on 2004-04-20
13
Medium Priority
?
182 Views
Last Modified: 2010-03-31

Hello, my web app allows users to but items, I have this working fine but i want to add an administration side that allows users to add new items to the database. Each item contains contains an image. What code do I need to load an image in java/jsp? Can an image be saved in a mysql database?
0
Comment
Question by:wallpaperpaste
[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
  • 3
  • 3
  • 3
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868899
You mean you want them to be able to upload an image file?
0
 

Author Comment

by:wallpaperpaste
ID: 10872478

Yes exactly
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10872566
You need to have an upload form containing a

<input type="file"

etc.

then use a class such as Jakarta commons FileUpload on the jsp side and then write it to mysql
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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

 
LVL 92

Expert Comment

by:objects
ID: 10873936
heres an example showing u how to insert image into database:
http://www.javaalmanac.com/egs/java.sql/InsertBinary.html
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10873966
your html would contain:

<form name="myform" action="upload.jsp" method="post" enctype="multipart/form-data">
  Image: <input type="file" name="myimage">
...

your jsp would contain:

DiskFileUpload upload = new DiskFileUpload();
List items = upload.parseRequest(request);
Iterator i = items.iterator();
while(i.hasNext())
{
    FileItem item = (FileItem) i.next();
    ...
}
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 100 total points
ID: 10878698
>> http://www.javaalmanac.com/egs/java.sql/InsertBinary.html

That one has had lot of discussion on: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20926879.html

;-)

Maybe you would like to read that to consider them....
0
 

Author Comment

by:wallpaperpaste
ID: 10923518

Hello people, i havent been on in a while, just trying your methods now
0
 

Author Comment

by:wallpaperpaste
ID: 10923900

Could you post some more sample code, im not making any real progress
0
 
LVL 92

Expert Comment

by:objects
ID: 10924572
i did above, you just need to take the FileItem and extract its contents.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10925441
Maybe you could post your own code as of now and we could try to shape it up a little.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 11678133
Sounds ok.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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