Answer the question
In order to leave comments, you need to log in
Uploading images using the Vkontakte API
The instructions for uploading files via APi https://vk.com/dev/upload_files says that after receiving the address for uploading files, the application must send a POST - a request in which there are file1-file5 fields, they contain the corresponding files. Question: how to send this request, namely, how should it look and what kind of file representation should be in it?
Answer the question
In order to leave comments, you need to log in
For those who are looking for how to send a POST request with a picture to vk api using php, I did it this way:
$link = $upl_url["response"]["upload_url"];
$lala = dirname(__FILE__)."/112.jpg";
$cfile = curl_file_create($lala,'image/jpeg','test_name.jpg');
$curl=curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $link,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array("photo" => $cfile)
));
Here is almost what you need:
www.webengineer.pro/wolfram/17-zagruzka-faylov-na-...
there the script from Wolfram Mathematica is considered in detail.
In conjunction with a php script on the server - it works fine. Perhaps you will be able to implement for the VKontakte API.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question