binary file upload from a form to a byte[]

Discussion in 'Java' started by Sigi, Jan 11, 2007.

  1. Sigi

    Sigi Guest

    I'm developing a web application which has to receive binary files uploaded
    by users through a form.

    This is the form (which is inside a JSP):
    <form method="post" action="MyServlet" enctype="multipart/form-data"
    id="upform">
    <p><input name="fileupload" size="30" id="fileupload" type="file"></p>
    <p><input id="button" style="width: 135px;" value="Invia" type="submit"></p>
    </form>

    In the servlet MyServlet, I need to write in the doPost method some code to
    receive the file from HTTP POST and store it into a byte array (without
    saving the file on disk)

    How can I do?

    Thanks.
     
    Sigi, Jan 11, 2007
    #1
    1. Advertising

  2. Sigi wrote:
    > I'm developing a web application which has to receive binary files uploaded
    > by users through a form.
    >
    > This is the form (which is inside a JSP):
    > <form method="post" action="MyServlet" enctype="multipart/form-data"
    > id="upform">
    > <p><input name="fileupload" size="30" id="fileupload" type="file"></p>
    > <p><input id="button" style="width: 135px;" value="Invia" type="submit"></p>
    > </form>
    >
    > In the servlet MyServlet, I need to write in the doPost method some code to
    > receive the file from HTTP POST and store it into a byte array (without
    > saving the file on disk)
    >
    > How can I do?
    >
    > Thanks.


    You can look at FileUpload API from Apache - specifically, the
    ServletUpload package.
    http://jakarta.apache.org/commons/f...mmons/fileupload/servlet/package-summary.html.
    You do not need to write files on the disk to manipulate them. I
    believe that is what you need.

    -cheers,
    Manish
     
    Manish Pandit, Jan 11, 2007
    #2
    1. Advertising

  3. Sigi

    Sigi Guest

    Manish Pandit wrote:
    > You can look at FileUpload API from Apache - specifically, the
    > ServletUpload package.

    It works perfectly.

    Thanks!
    SigiTM
     
    Sigi, Jan 12, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,593
    Bruce Barker
    Aug 3, 2005
  2. Guest
    Replies:
    2
    Views:
    10,995
    John Harrison
    Jul 26, 2004
  3. Replies:
    20
    Views:
    9,949
    licebmi
    Sep 7, 2009
  4. Replies:
    1
    Views:
    973
    Gabriel Genellina
    Nov 25, 2006
  5. daved170

    read text file byte by byte

    daved170, Dec 12, 2009, in forum: Python
    Replies:
    30
    Views:
    1,905
    Nobody
    Dec 16, 2009
Loading...

Share This Page