binary file upload from a form to a byte[]

S

Sigi

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.
 
M

Manish Pandit

Sigi said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top