locked
Allowing only excel files to be uploaded in SharePoint 2010 document library RRS feed

  • Question

  • Hi,

    I am aware of the "Prevent filetypes" section in the central administration of SharePoint that does not allow files of certain types to be uploaded in the entire farm. But, what I require here is: can we prevent files of certain types to be uploaded to a particular document library.

    What I am aware of is that we can have a default file type for a document library but then users can upload any type of file through the Upload button. So, either I need to prevent the files of different types from being uploaded or remove the Upload button.

    Please suggest the better option and its solution.


    Regards, Huzefa Mala, MCTS

    Friday, February 24, 2012 2:17 PM

Answers

  • Sure, not by configuration, but you can create a list event receiver that checks (in the item_adding event handler) the file extension and decides, based on the file ext, if the addition is allowed.

    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    Friday, February 24, 2012 2:25 PM

All replies

  • Sure, not by configuration, but you can create a list event receiver that checks (in the item_adding event handler) the file extension and decides, based on the file ext, if the addition is allowed.

    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    Friday, February 24, 2012 2:25 PM
  • Hi,

    You need to create a ItemAdding event receiver and checks for the files extension you can cancel the upload or do some functions.

    if (properties.ListItem.Name.Contains(".xyz") || properties.ListItem.Name.Contains(".abc")) { //properties.Cancel = true; } else { //run this code }

     

    Regards
    Friday, February 24, 2012 3:05 PM
  • Thanks for your reply but can there be a codeless solution to my problem.


    Regards, Huzefa Mala, MCTS

    Saturday, February 25, 2012 5:12 AM
  • Hi,

    You can create a workflow using SharePoint Designer. Its the simplest solution for your problem.

    Regards

    Saturday, February 25, 2012 4:55 PM
  • Thanks Arun.  Will the workflow be able to reject an upload (a) during the upload process or will it be (b) post-upload of files. 

    E.g. the workflow will fire and delete the record and inform the user that the record has been deleted due to invalid file type.

    If the workflow triggers in case (b) Post upload of files... it has limited use from users point of view.

    Please clarify.  thanks for the help.

    Monday, August 13, 2012 3:05 PM