Restrict file upload types/extensions

I’m looking for a method to restrict the types of binary files users may upload. I’d assume that would be a filter on the file extension, but I’m not sure how to accomplish it.

Also will be interested in doing the same with image uploads.

Any help is greatly appreciated - thanks in advance!

Assuming that your content type uses the item_file_attachment_ext shared field… Open the content type, click on the field to highlight it, click the validation tab. Check “Required” and add a rule with a validation type “Regular Expression.” Our main binary file content type has a regular expression of

.doc|.DOC|.docx|.DOCX|.gif|.GIF|.latex|.LATEX|.tex|.TEX|.pdf|.PDF|.ppt|.PPT|.pptx|.PPTX|.pps|.PPS|.ppsx|.PPSX|.rss|.RSS|.rtf|.RTF|.svg|.SVG|.tif|.TIF|.tiff|.TIFF|.txt|.TXT|.vcf|.VCF|.xml|.XML|.xls|.XLS|.xlsx|.XLSX|.zip|.ZIP

Only real drawback appears to be that the validation rule is not checked until after the entire binary is uploaded. With large uploads, this can be frustrating for end-users when their upload request is denied, after the upload.

Fantastic - works like a champ!

Thanks very much!

If you did a copy and paste of the below extensions, do note that there are spaces within the names that should not be there. I will of course assume that you just created your own set of extensions that you wanted ppl to be able to upload.

Yes, I did…our list is much smaller than that. :wink:

Thanks for the heads-up though!

I followed the example here but also discovered you can make the regex case insensitive using (?i) and saves you having to double up for lower and upper case.

So my regex looks like

(?i).(docx?|xlsx?|pptx?|dotx?|sxw|stw|sxg|sxc|stc|sxi|sxd|sxm|zip|tar.gz|pdf|txt|xml|csv)$

nice…much cleaner…Thanks!

Although, do note that for me (on RX 6.7) i had to get rid of the trailing $ before it would work…(i am putting that regexp on the validation field)