L
L
l_sev2017-06-04 20:56:37
PHP
l_sev, 2017-06-04 20:56:37

Why is the "photo" array empty?

$url = json_decode(file_get_contents("https://api.vk.com/method/photos.getMessagesUploadServer?access_token=".$this->token), true)["response"]["upload_url"]; 
$photo = __DIR__."/status1.jpg";
$post = ["photo" => curl_file_create($photo)]; 
$ch = curl_init($url);  
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data; charset=UTF-8')); 
$result = json_decode(curl_exec($ch), true); 
curl_close($ch);

Result: empty array photo[]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Zhilyaev, 2017-06-04
@kirill_782

Pick in the direction of the file. Maybe there is no access, maybe there is no file. Works for me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question