【发布时间】:2012-04-25 19:44:01
【问题描述】:
我希望使用 php-curl 发出以下 curl 请求:
curl "http://www.example.com/" -F "file=@foo.ext"
假设foo.ext 位于我发出请求的机器上,我需要如何在 PHP 中进行设置(使用 curl_init、_setopt 等)?
【问题讨论】:
我希望使用 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
【讨论】: