• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

load an image


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
wallpaperpaste
Asked:
wallpaperpaste
  • 3
  • 3
  • 3
  • +1
2 Solutions
 
CEHJCommented:
You mean you want them to be able to upload an image file?
0
 
wallpaperpasteAuthor Commented:

Yes exactly
0
 
CEHJCommented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
objectsCommented:
heres an example showing u how to insert image into database:
http://www.javaalmanac.com/egs/java.sql/InsertBinary.html
0
 
objectsCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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
 
wallpaperpasteAuthor Commented:

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

Could you post some more sample code, im not making any real progress
0
 
objectsCommented:
i did above, you just need to take the FileItem and extract its contents.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Maybe you could post your own code as of now and we could try to shape it up a little.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Sounds ok.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now