I am trying to upload an image to the server using the POST method, but it does not work. Here is the code:

VK.api('wall.getPhotoUploadServer', {}, function(data) { if (data.response) { upload_url = data.response.upload_url; //адрес для запроса alert( upload_url ); $.post( upload_url, {photo: 'http://zelenyar.ru/sites/default/files/styles/large/public/field/image/%D0%BE%D1%81%D0%B5%D0%BD%D1%8C.jpg' }, function(json) { hash = json.hash; alert( hash ); //не выводит }, 'json' ); } }); 

    1 answer 1

    1. You should not send a link to the image, but send the image itself in a multipart / form-data format.
    2. You will not be able to do this on browser JavaScript due to problems with CORS . Upload the image to your server and there already send the image to VK. I described a rough procedure for downloading a picture in PHP using cURL in this answer .
    • Can you clarify? Is it also impossible to send the image itself in multipart / form-data format to jvascript? Or are you just about the image from another site? - Andrei
    • It is impossible. CORS will not allow you to do this. - neluzhin