我希望使用 php-curl 发出以下curl 请求:
curl "http://www.example.com/" -F "file=@foo.ext"
Run Code Online (Sandbox Code Playgroud)
foo.ext假设 PHP位于我发出请求的计算机上,我需要如何在 PHP 中进行设置(使用curl_init、_setopt 等) ?
你会用
curl_setopt($curl_handle, CURLOPT_POST, TRUE);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array('file' => '@foo.ext'));
Run Code Online (Sandbox Code Playgroud)
加上您需要的任何选项。相关文档在这里: http: //php.net/curl_setopt