I have a SharePoint intranet site where I need to allow users to upload certain documents. These documents need to be only PDF files for example.

What is the simplest way to restrict the document library to only PDF (just checking the extension PDF is fine) ?

6 Answers 6


there is no OOB solution for this. But you could create an eventhandler (event receiver) and triggers on item adding, that checks the file name and if it's not the correct file extension just cancel event. /WW

  • I agree, this is the best option I would say Commented Jan 11, 2010 at 9:57
  • After the event receiver cancels the event, how to notify the user in the UI that the operation failed? Also this means that I need to let the user upload the entire file (can be many MBs) and then finally reject it, right? Commented Jan 11, 2010 at 10:05
  • Yea, the document has to be uploaded. You could do some smart stuff using JS on the newform.aspx if you would like to check it first though, but its not bulletproof Commented Jan 11, 2010 at 12:48
  • 1
    Maybe a combination if JS on the client and an event handler on the server. Btw if you are doing Event code, i recommend reading this article first regarding troubleshooting and oddities of event handling: msdn.microsoft.com/en-us/library/aa979520.aspx Commented Jan 11, 2010 at 23:08
  • Once newform.aspx is reached on a library, the file has already been uploaded, just not yet checked in. So JS on newform.aspx won't be useful.
    – Erin L
    Commented Apr 5, 2016 at 13:44

If you prefer not to deploy any of your own custom code to your WFEs then you may want to consider a simple SharePoint Designer workflow as well.

Have a look at this article that describes something similar and can easily be adapted (it renames a file from a workflow when it contains sensitive information in the file name).

Providing feedback to the customer is indeed a problem. An event receiver allows you to provide slightly better feedback than a workflow, but only slightly. SharePoint 2010 allows event receivers to provide better feedback.

  • I agree with creating a workflow in Designer. The workflow can email the user to provide feedback that their document wasn't accepted, including the name of the file, then delete the document.
    – Erin L
    Commented Apr 5, 2016 at 13:46

I know its not what you ask for, but for completeness i want to add that you can deny files by extension in Central Administration if you are using MOSS.

Manage blocked file types (Office SharePoint Server)

Anders Rask


You can create a workflow in SharePoint designer that moves non PDF files to another library, see http://www.documentmanagementworkflowinfo.com/sample-sharepoint-workflows/sharepoint-designer-workflow-move-document-one-library-next.htm for an example


Just Block all Other Extensions Except pdf. You Can Do this with the help of Sharepoint Central Admin->Security->Define Blocked File Types

  • 1
    Blocking files via Central Admin is not an option when using SharePoint Online.
    – user44512
    Commented Jul 24, 2015 at 6:21

you can add script to master page:

   //if current page is upload.aspx page of your document library
   if(location.pathname.indexOf('/_layouts/15/uplaod.aspx') != -1 &&
      RegExp('[?&]rootfolder=([^&]*)').exec(location.search.toLowerCase())[1].indexOf('/<yourSite>/<yourDocumentLibrary>') != -1){
          //set accept only types you want

it's not perfect because a user can change the dropdown types on dialog to all enter image description here

  • How do you add a script to the master page?
    – LUKER
    Commented Aug 3, 2021 at 17:53
  • /layouts/15/_catalogs/catalogs/masterpages find your master page name .master, edit the file - add <script>. you can edit also in SharePointDesigner
    – WantToDo
    Commented Aug 4, 2021 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.