File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Client to server fileupload using commons into database - beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Client to server fileupload using commons into database - beginner" Watch "Client to server fileupload using commons into database - beginner" New topic
Author

Client to server fileupload using commons into database - beginner

Crystal Bazil
Ranch Hand

Joined: Sep 28, 2004
Posts: 38
The problem: I wrote code using commons fileupload in a servlet which worked until I moved the code into production causing the file path(from client browser) to not exist(on sever). Doh.

So, I posted a message on here asking for some help and someone stated I should use the file input stream. I have been reading and searching so many articles, tutorials and messageboard threads that I am now completely confused and intimidated by this. I dont know what I am doing wrong or where to start!

What I need to get accomplished is this: The should be able to select a file off their local machine and upload it into the database - the actual file will upload in binary format and reside in the db.

There doesnt seem to be an abundant amount of examples of this out there or if there are I havent been able to find them.

1.) First of all, I dont really understand how the client and server relationship works. If I get a local machines' path and try to process this on the server side(via a servlet) then that path will not exist, correct?

2.) If the previous statement is true - then would I not want to process the fileupload in a servlet at all? Or, even how can I resolve the actual path to use. Is this even possible? This just confuses me.

I think I have the right code to upload the file and save it as a binary blob in the database. It works but just not from a client machine.

html



upload code



save to db



Some of my references:
I have followed this example for my code:
http://jakarta.apache.org/commons/fileupload/using.html

and I found this one(but I seem to be doing the same thing as they are):

<a href="http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21278328.html</a rel="nofollow">" target="_blank">http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21278328.html[/URL]



and this one(which I wonder if I should be doing):

<a href="http://www.devx.com/getHelpOn/Article/11698/1954?pf=true</a rel="nofollow">" target="_blank">http://www.devx.com/getHelpOn/Article/11698/1954?pf=true[/URL]


I am sorry if this is really long but I am overwhelmed by this at this point. Any help getting me on the right track would help. Thanks

Crystal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client to server fileupload using commons into database - beginner