只好硬著頭皮去研究,果真沒多久就遇到 Multipart Content-Type的問題
所以就去查請教了一下Google 大神,以下就記錄一下遇到的問題。
1. 目的 : 傳送一個表單,裡面包含 text and file 兩個欄位
2. HTML Syntax : Upload file
a. 畫面:
b. 語法
<form name="uploadfile" enctype="multipart/form-data"
action="test/upload_file.jsp" method="post">
SME-ID <input type="text" name="smeID"/>
remote path <input type="text" name="remote"/>
local path <input type="file" name="lcoal" size="50" maxlength="20" />
</form>
action="test/upload_file.jsp" method="post">
SME-ID <input type="text" name="smeID"/>
remote path <input type="text" name="remote"/>
local path <input type="file" name="lcoal" size="50" maxlength="20" />
</form>
3. 透過Wireshark 擷取封包發現
問題:在圖片裡的
(1) boundry=---------------------------101321613017111
(2) -----------------------------101321613017111 #起頭多了兩個--
(3) -----------------------------101321613017111-- #起頭結束多了兩個--
當下覺得太奇怪,原先記憶中,這boundry的部分與分割部分還有結束應該都是一樣的。
4. 結果:由http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html 得知
Thus, a typical multipart Content-Type
header field might
look like
this:
Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0pThis indicates that the entity consists of several parts, each itself with a structure that is syntactically identical to an RFC 822 message, except that the header area might be completely empty, and that the parts are each preceded by the line
--gc0p4Jq0M2Yt08jU534c0pThe encapsulation boundary following the last body part is a distinguished delimiter that indicates that no further body parts will follow. Such a delimiter is identical to the previous delimiters, with the addition of two more hyphens at the end of the line:
--gc0p4Jq0M2Yt08jU534c0p--
沒有留言:
張貼留言