html - php如何用cURL模拟一表单中同时有字符串和文件?
巴扎黑
巴扎黑 2017-04-10 14:30:40
0
2
435

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

巴扎黑
巴扎黑

reply all(2)
小葫芦
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

迷茫

默认表单是没法同时POST字符串和文件的,可以考虑字符串用GET通过URL传递,同时POST文件。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template