This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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

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.


upload code

save to db

Some of my references:
I have followed this example for my code:

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

<a href="</a rel="nofollow">" target="_blank">[/URL]

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

<a href="</a rel="nofollow">" target="_blank">[/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

Have you checked out Aspose?
subject: Client to server fileupload using commons into database - beginner
It's not a secret anymore!