• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload Contents

 
ford Darcy Jr
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Struts, this application demonstrates how to
insert BLOB's into the database:

http://strutsblobapp.sourceforge.net/
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic