S
S
Serg-shumakov2016-02-02 21:28:15
PHP
Serg-shumakov, 2016-02-02 21:28:15

How to upload images of VKontakte products?

I do everything according to the instructions
1) I get the address for uploading via the "photos.getMarketUploadServer" method
2) I send a POST request to the received upload_url, where I pass the image in the "file" parameter
3) In response I get "ERR_UPLOAD_BAD_IMAGE_SIZE: owner photo min size 200x200 your size 0x0 4", but the image is definitely larger than 200x200.
To eliminate the error, I made an html form and sent the file through it, the result is similar:
c8d2d83274bf4ab0b044dce73ae9291d.png
PHP code:

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => ['file' => '@/var/www/site/images/image.jpg'],
    CURLOPT_URL => $url,
]);
$result = curl_exec($ch);
curl_close($ch);

Has anyone else experienced this issue or am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Orlov, 2016-02-08
@Serg-shumakov

The API gives incorrect information about the allowed width and height of the image. It must be at least 400 pixels wide and high. This warning is displayed if you add a product image through the web interface.

E
Eugene, 2016-02-02
@Nc_Soft

try like this

curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => new CURLFile($path)]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question