K
K
Kypaku2013-11-16 13:13:03
API
Kypaku, 2013-11-16 13:13:03

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

4 answer(s)
P
plaha_anton, 2015-02-06
@plaha_anton

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)
      ));

B
bumbay, 2013-11-16
@bumbay

Here you can see how it is implemented .

K
Kypaku, 2013-11-16
@Kypaku

@bumbay file_get_contents($url); How is this function set up?

V
VsVoland, 2013-12-16
@VsVoland

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 question

Ask a Question

731 491 924 answers to any question