网页文件
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form enctype="multipart/form-data" action="fileupload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type="file" name="filename">
<input type="submit" value="upload">
</form>
<form>
</body>
</html>
效果就是简单文件选择和提交按钮。
问题在于要响应 action 操作,提取文件内容。
request 的内容大致为:
POST /xxxxx HTTP/1.1
Host: 192.168.88.2:23456
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.17pre) Gecko K-Meleon/1.6.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://192.168.88.2:23456/upload.html
Content-Type: multipart/form-data; boundary=---------------------------265001916915724
Content-Length: 2132
-----------------------------265001916915724
Content-Disposition: form-data; name="MAX_FILE_SIZE"
2000000
-----------------------------265001916915724
Content-Disposition: form-data; name="filename"; filename="x.html"
Content-Type: text/html