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

WBOY
Release: 2016-06-06 20:49:20
Original
1050 people have browsed it

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

回复内容:

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

<code>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);
</code>
Copy after login

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!