我正在尝试转换以下 CURL:
curl -X POST \
-H "Content-Type: image/jpeg" \
--data-binary '@myPicture.jpg' \
https://api.parse.com/1/files/pic.jpg
到 PHP:
$ch = curl_init();
$data = array('myPicture.jpg' => "@myPicture.jpg");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
$headers = array();
$headers[] = "Content-Type: image/jpeg";
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_URL, 'https://api.parse.com/1/files/myPicture.jpg');
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
curl_close($ch);
但我的回应是false
。这是我从中得到的print_r(curl_getinfo($ch), true)
:
Array
(
[url] => https://api.parse.com/1/files/myPicture.jpg
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 0.28
[namelookup_time] => 0.187
[connect_time] => 0.218
[pretransfer_time] => 0.28
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
)
关于为什么这不起作用的任何想法?谢谢!