Solved

load an image

Posted on 2004-04-20
13
174 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
  • 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
 
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 25 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle earned 25 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:mayankeagle
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:mayankeagle
ID: 11678133
Sounds ok.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now