Skip to main content

how to retrieve the url string of uploaded file outside the cloudinary.v2.uploader.upload() method scope

Comments

1 comment

  • Aditi Madan

    Hi Felix,

    I will recommend declaring the variable as a global variable and that way you can access it from any function.

    Here is an example:

    var ....;
    var iurl;  //global variable
    app.post('/', function (req, res){

    cloudinary.uploader.upload(path, function (result) {

    for(var attributename in result){
    if(attributename=='url'){
    iurl=result[attributename] //assigning value to iurl variable
      }
     }
    });

    myLogger(iurl); //calling a function outside of app.post and passing iurl value
    });

    var myLogger = function (reqs) {
    console.log(reqs); //printing the value
    }
     
     

     

    0

Post is closed for comments.