我希望使用 php-curl 发出以下 curl 请求:
curl "http://www.example.com/" -F "file=@foo.ext"
假设
foo.ext
,我需要如何在 PHP 中进行设置(使用 curl_init、_setopt 等)住在我发出请求的机器上?
最佳答案
你会用
curl_setopt($curl_handle, CURLOPT_POST, TRUE);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array('file' => '@foo.ext'));
加上您需要的任何选项。相关文档:http://php.net/curl_setopt
关于php - 如何使用 php-curl 发布存储在本地的二进制文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10322646/