aspose file tools*
The moose likes Servlets and the fly likes File Upload Contents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "File Upload Contents" Watch "File Upload Contents" New topic
Author

File Upload Contents

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

I am able to upload files onto the server using com.orielly.Servlet.MultipartRequest. But how do I insert the file upload contents such as filename into the database.

Can anybody please help.

Thanks
Jim Kenny
Greenhorn

Joined: Nov 18, 2004
Posts: 6
Hi :

Lots of people have problems when they first try to do this because they don't set the parm in thier <form tag correctly. You need to set if for multipart... . I forget the syntax...

Check that first.

Peace,

Jim
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If he's able to save the file, then he must already be using multipart.

request.getParameter() doesn't work with multipart forms.
You will need to use the methods provided by the upload libraries you are using.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Dont really know what is your problem. Bens reply might help you.

And if you are talking about how to get the file name from the file item already uploaded then there must be some method like,

fileItem.getName()


However, I used to do file uploading stuff with apache commons upload. It is the method there in FileItem class, i guess.

[edited]
But IE sucks. It is giving me the whole damn path instead of a file name, while doing fileItem.getName().
[ February 04, 2005: Message edited by: Adeel Ansari ]
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
If you are using Struts, this application demonstrates how to
insert BLOB's into the database:

http://strutsblobapp.sourceforge.net/
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
If you use Jakarta Commons FileUpload project, once you have a FileItem it is simply a matter of getting the byte[] of the file and writing that to a Blob.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload Contents