You need to sign in to do that
Don't have an account?
Emmanuel Corona
Attach only pdf or zip files
Greetings!
I have my page for upload files but i want to restrict the file type only for PDF or ZIP
i have in code:
<apex:inputFile accept=".zip,.pdf*" value="{!attach.body}" filename="{!attach.name}" required="True"/>
But on Iexplorer, Mozilla, Chrome and safari i can upload any type of files.
Thank you so much!
For the JavaScript, something like this should work:
All Answers
1. You can use javascript on the client side to block the upload.
Here's an example from http://murthyvvr.blogspot.com/2013/05/apex-input-file-type-validation-using.html
(Have not tested this, so cannot vouch for it.)
2. In any case, you should check on the server side to make sure the extension is OK.
Assuming you are creating an Attachment object with the file, if the object name is atm, you can do something like:
For the JavaScript, something like this should work:
Thank you Salesforce Solutions