Upload only pdf file

Hi all,
is there a way to restrict user to upload only pdf file?
Thanks

Use condition for example, When This FileUploader’s value’s file name contains “.pdf”

1 Like

Use “Better uploader” plugin and pass the file-type you want to upload,

Any relevant plugin?

Ankur mentioned one of them already above. Also:

I have a temporary solution for this:

  1. Put an id on your file uploader (in this example is “restrictedInput”)
  2. Put a html element on your page
    3)put this script on html element:
<script>
let intervalId = setInterval(function() {
const acceptedTypes = ".pdf"; 
  const inputElement = document.getElementById("restrictedInput").querySelector("input");
  if (!inputElement.getAttribute("accept") || inputElement.getAttribute("accept") !== acceptedTypes) {
    inputElement.setAttribute("accept", acceptedTypes);
  } else {
    clearInterval(intervalId);
  }
}, 200);
</script>

If you use it for more than one file uploader in your project you have to create one html element for each file uploader and put this function on each. You also have to change the interval variable name, in this example is “intervalId” that is at start “let intervalId = setInterval” and at the end “clearInterval(intervalId);” you should have one html element for each input you want to restrict and each html element with this function must have a different interval variable name.

Note that this function is executed each 200ms (the time at the end) until the input has changed value, so if you have the file uploader hidden or in a popup it will be no able to change nothing until the popup/file uploader show up and will continue running each 200ms, in that case you might want to increase this value to 1000 (1s)

Here is the editor sample:

and here the preview:

This might help : How to upload only .pdf or .png files in multi-file uploader in Bubble