Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

File Uploads in Java (Servlets)

Options
  • 08-04-2003 1: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 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 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