消息体需要拼凑成下面的字样:
header可以用函数实现;
如果用apache的httpmime就不用自己组装这样的字符串了,给喜欢刨根和看数据的朋友;
---9HDpTc9h_JwKe_wZFJilhLJnSa1bhBQc 分隔符,这里与头区分
Content-Disposition: form-data; name="file"; filename="file.txt"Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
filehere
filecontent #文件体,为简单起见很简单的小文件
---9HDpTc9h_JwKe_wZFJilhLJnSa1bhBQc
Content-Disposition: form-data; name="id" #参数1的名称
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
id123 #参数1的值
---9HDpTc9h_JwKe_wZFJilhLJnSa1bhBQc
Content-Disposition: form-data; name="type"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit #注意,这行8bit前面红色部分空格必须有,否则可能报错:unquoteMediaTypeParameters
2
---9HDpTc9h_JwKe_wZFJilhLJnSa1bhBQc
Content-Disposition: form-data; name="size"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
21
---9HDpTc9h_JwKe_wZFJilhLJnSa1bhBQc-- #分隔符的结束符
本文详细介绍如何手动构造一个MIME多部分请求体,包括设置正确的分隔符、定义文件和参数部分的数据类型及编码方式,并附带了一个具体的例子。

被折叠的 条评论
为什么被折叠?



