Can't upload without full file path. Can't get file path, only "C:\fakepath". Then, how?
I want to upload local files with:
cloudinary.v2.uploader.upload("/home/sample.jpg", function(error, result) {console.log(result, error); });
However, I can only get the file name from HTML5 <input> or, when <input> is in a form that is submitted, the file path answer we get is "C:\fakepath\filename...".
I want to use plain javascript / HTML rather and provide my own look & feel rather than use Cloudinary's widget. How can I do it? How the widget does it?
-
Hi Julio,
"cloudinary.v2.uploader.upload" is a method from our server-side Node SDK, but it sounded from your question like you might be trying to use it from client-side Javascript code - if so, that's not possible and it will probably not work for you.
To make upload requests from client-side javascript, you can use our JQuery SDK, or make HTTP requests to the API endpoint directly, and there's more information on this documentation, just below where our Upload Widget is mentioned: https://cloudinary.com/documentation/javascript_image_and_video_upload#upload_options
If you are indeed making the requests from server-side Node code, the most likely explanation is that the data submitted by the frontend to your Node code hasn't been processed correctly before you try to send it to our SDK - in that case, please check any middleware you're using to turn the form Data into File objects (for example, Multer is commonly used for that, including in some of our examples: https://github.com/expressjs/multer )
Regards,
Stephen
0
Post is closed for comments.
Comments
1 comment