I do not know how it happened, but I can not transfer the picture to the VK server. Here is the actual request:
$ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 90); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url);//тут урл, взятый с запроса photos.getUploadServer curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, array("file1" => '@'.urlencode($caption).';type=image/png')); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); $ans = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); All data is photo_list in response, except for photo_list , which is [] . The info shows that the file does not transfer - Upload_Content_Length - 23.
But why, I can not understand. Please help. Thank you in advance!
PS Changed Content-type to multipart , sent with and without @ , sent with urlencode and without, c ';type=image/png' and without.
I also tried POSTFIELDS to do this:
'file1=@'.urlencode($caption).'; type=image/png' 'file1=@'.urlencode($caption).'; type=image/png' , again with different parameters.
$caption contains the full path to the file (on the computer), the path is taken from the folder scanning function, plus I displayed the postfields, there can be no errors here.
Content-Type: multipart/form-data. cleanurlencode. - zenden2kcurl_setopt($ch, CURLOPT_HTTPHEADER,- zenden2k