• Post Reply Bookmark Topic Watch Topic
  • New Topic

Client to server fileupload using commons into database - beginner  RSS feed

Crystal Bazil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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="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 >" 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

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!