Javascript - how to find url or public id with upload widget
I upload using the widget..
Upon success, how do I get the public ID or URL
--------------------------- Code is below.
(error, result) => {
if (!error && result && result.event === "success") {
GET PUBLIC ID OR URL HERE????
console.log('Done! Here is the image info: ', result.info);
}
});
-
Hi Steve,
Thanks for your message.
You can get the public_id and URL of the uploaded asset in the result.info object that you have in the callback function following a successful upload.
You can access the public_id and URL respectively:
result.info.public_id
result.info.secure_urlI have created a short JSFiddle with the same code that prints out the secure_url for the uploaded asset:
https://jsfiddle.net/wgeohcjr/
You could fill in your cloud_name and the unsigned upload preset and try this out.
Please let me know how this goes.
Best regards,
Aleksandar
-
Hi Brian,
Are you using the exact code in the above example and also is the file actually uploading to your account but not printing the secure_url?
I tested with the above example and upon successful upload, the secure_url is printed in the console. Please see the short recording below.
Looking forward to your response.
Best regards,
Aleksandar
Please sign in to leave a comment.
Comments
6 comments