php如何用cURL模拟一表单中同时有字符串和文件?


RT,php,想用curl同时发送文件和字符串,就是模拟一个表单中既有一堆字符串还有文件。

php curl HTML 表单 http

冯月·玄之丞 10 years, 7 months ago

 curl_setopt($curl_handle, CURLOPT_POST, 1);
$args['file'] = '@/path/to/file';
$args['a'] = 'blablabla...'; //and so on
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $args);

更多的内容: https://wiki.php.net/rfc/curl-file-upload

wunian answered 10 years, 7 months ago

Your Answer