Search code examples
htmlcssreactjscdncloudinary

Cloudinary widget: Setting resource type does not limit the type of files the user can upload


According to the documentation, this is how you limit the type of file the user can upload:

enter image description here

This is how I implemented it in my code:  
  var myWidget = window.cloudinary.createUploadWidget(
    {
      cloudName: "456aefaefaefayrw",
      uploadPreset: "dadazf",
      sources: ["local"],
      resourceType: "image",
    },
    (error, result) => {
      if (!error && result && result.event === "success") {
        console.log("Done! Here is the image info: ", result.info);
      }
    }
  );

But, the user can still see ALL types of files:
enter image description here


Solution

  • Cloudinary allows uploading pdf as image type and videos when passed as image are uploaded as an image. You can use clientAllowedFormats option in the upload widget and that will block any other format from uploading other than the one specified or you can mention that in the upload preset.