Java Reference
In-Depth Information
data" >
File:
<input type="file" name="file" id="file" /> <br/>
Destination:
<input type="text" value="/tmp" name="destination"/>
</br>
<input type="submit" value="Upload" name="upload"
id="upload" />
</form>
</body>
</html>
A POST request method is used when the client needs to send data to the server as part of
the request, such as when uploading a file or submitting a completed form. In contrast, a
GET request method sends a URL and headers only to the server, whereas POST requests
also include a message body. This allows arbitrary-length data of any type to be sent to the
server. A header field in the POST request usually indicates the message body's Internet
media type.
When submitting a form, the browser streams the content in, combining all parts, with
each part representing a field of a form. Parts are named after the input elements and
are separated from each other with string delimiters named boundary .
This is what submitted data from the fileupload form looks like, after selecting
sample.txt as the file that will be uploaded to the tmp directory on the local file sys-
tem:
Click here to view code image
POST /fileupload/upload HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data;
boundary=---------------------------263081694432439
Content-Length: 441
-----------------------------263081694432439
Content-Disposition: form-data; name="file"; filename="sample.txt"
Content-Type: text/plain
Data from sample file
-----------------------------263081694432439
Content-Disposition: form-data; name="destination"
/tmp
-----------------------------263081694432439
Content-Disposition: form-data; name="upload"
Search WWH ::




Custom Search