Answer the question
In order to leave comments, you need to log in
How to upload an image to VK using JavaScript?
Generally. There is an image, can it be uploaded to VK to the user on the wall or in a separate album (no matter where) using Javascript ? Please describe in more detail. If not difficult)
Answer the question
In order to leave comments, you need to log in
From the browser directly to VK will not work . From nodejs or Electron - easily.
The key point here is the response of the VK server to upload a picture file to them. They respond without CORS headers and the browser considers such a response unsafe, making it inaccessible to JS scripts.
Uploading files to VK is well described in their documentation . Three steps:
All this is easily done in JavaScript, but the security policy of browsers does not allow receiving a response from a foreign server if it is not accompanied by special HTTP headers. And VK does not give them for some of its own “security” reasons, as their technical support answered me:
Therefore, you can only upload through your own server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question