Javascript - how to find url or public id with upload widget

Comments

6 comments

  • Avatar
    Aleksandar Kostadinov

    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_url

    I 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

    0
    Comment actions Permalink
  • Avatar
    Brian Stewart

    secure_url is undefined in the above sample

     

    0
    Comment actions Permalink
  • Avatar
    Aleksandar Kostadinov

    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.

    https://cl.ly/40405121d735

    Looking forward to your response.

    Best regards,

    Aleksandar

    0
    Comment actions Permalink
  • Avatar
    Scott Hwang

    I tried the code at jsfiddle too. I always get "undefined."

    0
    Comment actions Permalink
  • Avatar
    Scott Hwang

    Hi. I figure it out. I had to set asynchronous to "off" in my upload preset.

    0
    Comment actions Permalink
  • Avatar
    Francis Tagbo

    Hi Scott,

    Thanks for your update. 

    If there's anything else that we could help with, please don't hesitate to reach us. 

    0
    Comment actions Permalink

Please sign in to leave a comment.