消息体需要拼凑成下面的字样:
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-- #分隔符的结束符