uploadcare / uploadcare-widget

Uploadcare Widget, an ultimate tool for HTML5 file upload supporting multiple file upload, drag&drop, validation by file size/file extension/MIME file type, progress bar for file uploads, image preview.

Home Page:https://uploadcare.com/products/file_uploader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

preferredTypes not working

luisrudge opened this issue · comments

Even though I'm addingpreferredTypes, it's not blocking other files from being selected.

    const dialog = uploadcare.openDialog(initialFiles, null, {
      publicKey: process.env.REACT_APP_UPLOADCARE_KEY,
      multiple: true,
      preferredTypes: 'image/*'
    });

image

image

Hi @luisrudge, sorry for such a long delay with the response! The preferredTypes option implements different functionality. It tells social/cloud services APIs which file formats you'd like to receive. For example, by default, Google Drive API returns documents in PDF format, but with this option, you can force it to returns XLSX/DOCX instead.

In order to hide unwanted file types in the system dialog, use the inputAcceptTypes option. Note that it affects only local files, and users still can disable the filter and select any file. To prevent uploading files of unwanted type, size, etc. use file validation.