I need some help in my lasts steps when uploading a file to cloudinary from node.js (using sails.js)
I give you the code below: Controller:
var cloudinary = require('cloudinary');
index: function(req, res){
cloudinary.config({
cloud_name: 'cloud_name',
api_key: 'api_key',
api_secret: 'api_secret'
});
var cloudinary_cors = "http://" + req.headers.host + "/cloudinary_cors.html";
var uploader = cloudinary.uploader.image_upload_tag('image_id', { callback: cloudinary_cors, html: { multiple: 1 } });
var cloudinary_script = cloudinary.cloudinary_js_config();
return res.view('myaccount/myaccount', { uploader: uploader, cloudinary_script: cloudinary_script });
}
Then my scripts are these:
<!--SCRIPTS-->
<script type="text/javascript" src="/js/dependencies/sails.io.js"></script>
<script type="text/javascript" src="/js/dependencies/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="/js/jquery.fileupload.js"></script>
<script type="text/javascript" src="/js/jquery.cloudinary.js"></script>
<%-cloudinary_script%>
<!--SCRIPTS END-->
And finally my form:
<form action="" method="post" enctype="multipart/form-data" class="upload_form">
<div class="form-group">
<label>Profile picture</label>
<%-uploader%>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>
Well, everything works fine, it uploads my file when i select it (i couldn't make it work without auto-upload when selecting the file) so... first i need to get notified in the controller when the file is fully uploaded and get the image id so i can save it in the database, i found some guides but i couldn't make it work either, this for example: Can't get image_id from Cloudinary in NodeJS hope you can help me, thanks again!