Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

File Uploads in Java (Servlets)

  • 08-04-2003 01:03PM
    #1
    Closed Accounts Posts: 1,719 ✭✭✭


    right. i'm trying to upload a file from a HTML form to a Servlet ( so i can save it to disk later,but that's not the problem right now ).

    So as much as i've scoured the Java Doc's ( J2EE ) for a solution to my problem. i'm completly stumped. i have no idea where to start. I've tried to get a few tutorials on the internet, but they all use a prepackaged,pre complied class to do it.

    So my question is, from a Servlet how do you read a file in from a HTML from (i know how to setup the from and how to read parameters off the form,it's just how to deal with a <input type="file"> tag that i cant deal with in java)

    Thanks in advance.


Comments

  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭Zab


    You can do all the work yourself... or you can use a third party API such as smartupload from jspsmart.

    Zab


  • Registered Users, Registered Users 2 Posts: 1,186 ✭✭✭davej


    There is no quick and easy way to do this without using external libraries.

    You can use the oreilly libraries to handle multipart/form-data:

    http://www.servlets.com/cos/index.html

    See the MultipartRequest and MultipartParser classes.

    davej


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    The O'Reilly one is really easy to use and very flexible too.


  • Closed Accounts Posts: 679 ✭✭✭ciano


    Originally posted by Enygma
    The O'Reilly one is really easy to use and very flexible too.

    yup, I'd agree with that. Have a look at O'Reilly's solution and then maybe have a go at it yourself afterwards.


Advertisement