hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rustad, Aaron" <ARus...@Online-can.com>
Subject Problems Upload a file.
Date Mon, 08 Dec 2003 18:07:24 GMT
I am trying up upload a file to a servlet, but I am not sure that it is 
working as it should. I hope that someone out there can point out 
what/if I am doing wrong.

I have this code that uses HTTPClient 2.0r2:

ByteArrayPartSource partSource = new ByteArrayPartSource("file.txt", 
theBytes);
FilePart filePart = new FilePart("input-data", partSource);
mpPostMethod.addPart(filePart);

But when it hits the servlet (with the above code), the "input-data" is 
considered a simple form field.
When a use a form that is embedded into a web page(see below), it is not 
a form field.

<form action="./upload.do" enctype="multipart/form-data" method="POST">
 <table width="75%" border="1">
  <tr>
    <td>From: </td>
    <td><input type="text" name="from" value="asdf"/></td>
  </tr>

  <tr>
    <td>To: </td>
    <td><input type="text" name="to" value="qwer"/></td>
  </tr>
  <tr>
    <td>Version: </td>
    <td><input type="text" name="version" value="1.5"/></td>
  </tr>    
  <tr>

    <td>File: </td>
    <td><input type="file" name="input-data" value="C:\\demon.gif"></td>
  </tr>
</table>
<input type="submit" value="Submit"/>
</form>

Any help is greatly appreciated.
Thanks!
Aaron.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message