i am using SharePoint online and was wondering how to allow user to only upload PDF file,IF there any out of the box solution would be great.

  • use custome file upload control and check file extention using jquery in content editor webpart
    – kumar
    Oct 25, 2017 at 16:39

2 Answers 2


There is no OOTB solution to restrict file with specific extension. You can create event receiver and override "ItemAdding" method.In this method,you can check the extension of file. If you want to restrict a specific file you can cancel the event.


You could try below script to list form.

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
    function PreSaveAction() {
        var Check=true;
        $('#idAttachmentsTable').find('tr').each(function () {
            var filepath = $(this).find('span[dir="ltr"]').text();
            if (filepath.indexOf(".pdf")=="-1") {
                Check = false;
                alert("Not PDF"+filepath);                

        return Check;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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