求助,怎么用curl上传文件同时post中文字符串?
-F/--form好像不能接受中文用-d/--data可以,但不能上传文件
可惜-d和-F不能混用
有办法在上传文件的同时发送中文么?
比如这个
<form method=\"post\" action=\"memcp.php?action=profile\" enctype=\"multipart/form-data\">
<input type=\"text\" name=\"nicknamenew\">
<input type=\"file\" name=\"customavatar\">
</form>
如果用-F "nicknamenew=昵称",结果是空白
如果手工给昵称urlencode,用-F "nicknamenew=%E6%98%B5%E7%A7%B0",结果就直接是%E6%98%B5%E7%A7%B0
用-d/--data的话,-d "nicknamenew=%E6%98%B5%E7%A7%B0"就行了,不过没法上传文件
我糊涂了,求指点迷津 到curl邮件列表上问吧. 看了一下手册http://curl.haxx.se/docs/manpage.html
--data-urlencode选项可能是你想要的. 别笑话,咱土鳖,还没用过邮件组呢023
--data-urlencode和--data类似,都是对应application/x-www-form-urlencoded,不能用来上传文件
--form是对应multipart/form-data,可以用来上传文件
-F/--form <name=content>
(HTTP) This lets curl emulate a filled in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC1867.
看了下RFC1867,好像默认接受7bit的encoding,non-ascii字符需要修改Content-Transfer-Encoding
这些rfc规范咱也没接触过。。。
怎么在curl里面实现完全没有头绪 暂时解决了。。。
用-F \"nicknamenew=<nickname.txt\"
文本用对应编码,比如utf-8保存在nickname.txt
可惜本想完全用命令行搞定的,这下还需要多建几个临时文件
页:
[1]