File Upload Type

  • 2
  • Question
  • Updated 4 years ago
  • Answered
Is there a way to limit the type of file a user can upload?  I only want PDF files to be allowed...
Photo of Scott


  • 2,732 Points 2k badge 2x thumb

Posted 5 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 45,308 Points 20k badge 2x thumb
Maybe a validation rule on the "Content Type" field of the attachment object? 
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,026 Points 5k badge 2x thumb
If memory serves, workflow rules don't support attachments.  You will probably need Apex here.

Here's a nice example to get you started:
Photo of Pat Vachon

Pat Vachon, Champion

  • 46,404 Points 20k badge 2x thumb
hmmm... this is apex. Since this is the case, can we put together something more meaty using a visualforce page with a skuid:page visualforce component for all things related to attachments. ie. require an description upon uploading.

Shooting from the hip on this one.
Photo of Christopher Johnson

Christopher Johnson

  • 694 Points 500 badge 2x thumb
Curious if anyone got a solution working here...and whether you did it with attachments to the object or the lookup field (to the custom skuid file object).
Photo of Bill Fox

Bill Fox

  • 8,990 Points 5k badge 2x thumb
Has anyone come up with a solution for this one?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 18,656 Points 10k badge 2x thumb
Photo of Thimo


  • 1,280 Points 1k badge 2x thumb
I have posted something like this before. 

A solution is Javascript. This prevents the user from picking other filetypes than specified. But this is not foolproof since JS could be disabled in the browser.

$('INPUT[type="file"]').change(function (event) {
var ext = this.value.match(/\.(.+)$/)[1]; switch (ext) { case 'pdf': break; default: alert('This Filetype is not supported.'); this.value = ''; window.stop(); } });