1
votes

I am working on a node.js project and trying to upload images using the cloudinary npm module.

The function for uploading the image requires the image and the callback. However, the form sends a fakepath\image. How do I get the image for the upload from the html form?

1

1 Answers

0
votes

Without a code sample, it's hard to be sure, but I believe you're passing the file to your app in an HTML form, and then you want to post that image to Cloudinary using the node.js SDK?

If so, the sample app included with the node SDK has a brief example of how to do that.

Take the file uploaded to your server, and pass it to the call to Cloudinary's SDK.

In the SDK example, it looks like this:

 var imageFile = req.files.image.path;
  // Upload file to Cloudinary
  cloudinary.uploader.upload(imageFile, {tags: 'express_sample'}) ...

In the example, image was the name of the form field on the HTML form:

<input id="photo_image" name="image" type="file" />