How can i restrict file types for attachments?

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Photo of Ismail

Ismail

  • 0 Points

Posted 6 years ago

  • 0
  • 1
Photo of Jeff

Jeff

  • 20 Points
Hi Ismail,

I am sorry, but at this time it's not possible to configure a file attachment field so that only certain types of files are allowed. This is a great suggestion though, and I recommend you submit it to our User Voice site here:

https://quickbase.uservoice.com

This will give the community an opportunity to vote on your suggestion and help our Product Managers evaluate which features are most requested by our customers.

Thanks!
Jeff
Photo of Ismail

Ismail

  • 0 Points
Thanks for the reply Jeff! I'll  make sure to submit this shortly.
Photo of Harrison Hersch (MCF)

Harrison Hersch (MCF), Champion

  • 40 Points
Hi - while there is no native feature for this, there is a fairly straight forward, simple and creative solution.

1) Setup a Formula-Text field. Something like this formula would work fine:
var text file = ToText([Attachment]); //convert the name of the file attachment to textvar text extension = Right($file,"."); //parse apart the file attachment text so we get the extension (all characters after the last period)$extension //show the extension
* Replace [Attachment] with the name of your field.
* I use variables here just because I find them cleaner to illustrate the logic. Certainly one long text string would work fine.

2) Setup a Formula-Checkbox field which will contain the logic for your file extensions:
If( Contains([Description],"PDF") or Contains([Description],"PNG"), true, false)

3) Set a form rule to prevent the save when this box = false.

A few notes:
* You could do this all in one field quite easily. I just like this approach because it is kind of like "showing your work" and allows you to quickly debug if necessary.
* The reverse could easily be done to only prevent the save when the box is checked, if you wanted to explicitly deny some document types as opposed to this approach which only allows two choices.

Let me know if you need any help!

Photo of Dan M

Dan M

  • 74 Points
The formula required some adjustments, but works.  However, the rule to prevent the save is not triggering, and still allows ANY file type to be saved.  Is this a Quickbase bug?
Hi Dan,

Can you please tell me which file type you want to restrict?

I have another solution for you.

Thanks,

Gaurav
Photo of Dan M

Dan M

  • 74 Points
We need to restrict .bat, .exe, .wav  more specifically, we want to restrict the files to pdf, jpg, and gif only.

Thanks,
Dan
(Edited)
Dan,
A Native solution is to sign up for early access to Automations or wait for the May General Availability release.

Then set up an Automation to based on a formula field detecting that the suffix of the file is invalid and delete the record.  So it will upload and get deleted immediately.