How to disable “overwrite exisintg files” checkbox in a Picture or Document Library

Posted: August 13, 2013 in Customization, Master Page, SharePoint
Tags: , , , ,

This request was came up to us when we needed a picture library that every time users should be able to upload their own images to it without overwriting the others images. The problem was “overwrite existing files” checkbox.

There is a solutions for this issue (not useful in my opinion) which is about modifying the “upload.aspx” page on the server (_layouts folder). However it will affect farm scope. we need it just for a specific library.

I found a solution based on jQuery. I’m not very expert in terms of coding and JavaScript, however I tried my own way and made a simple code after some hours! 😀 This workaround helped us. So I’m gonna share it with you here and hope that would be helpful for you too. Here is the summery of my workaround:

  1. Find if the prompt or page (upload) is related to our list (line 4)
  2. Find the check box and un-check it (line 6-7)
  3. Hide the section and also its description (line 8)

Here is the code:

$(document).ready(function()
	{
	var form = $('form');
 	if ( form.attr('action').indexOf('YOUR 36 character List ID - Without Braces') > -1 )
	 	{
	 	var checkbox = $('#ctl00_PlaceHolderMain_UploadDocumentSection_ctl03_OverwriteSingle');
	 	checkbox.prop('checked',false);
	 	checkbox.parent().hide();
	 	var multiple = $('#ctl00_PlaceHolderMain_UploadDocumentSection_ctl03_UploadMultipleLink');
	 	multiple.hide();
	 	}
	}
);

Note:

  • on line 4 you must replace the ListID with you own Picture library ID or document library ID
  • Put this script in your default master page also link to jQuery file
Advertisements
Comments
  1. mark says:

    Thanks for the post.
    1. Can you elaborate a bit more on line 9 please (not sure what to insert here)?
    2. If we have multiple libraries – do we need to copy entire code for every library?

    • Navid.R says:

      Hi Mark. line 9 is about selecting the tag which contains “upload multiple documents” link. that is the id of the tag. If you want to understand it better try to see the source code of the upload page (f12) and find the tag.

      second question: yes because I have specified a specific library ID (line 4). however if you omit the if condition, as long as the code is available in your master page, it will affect every picture library.

  2. Randy says:

    I can’t seem to get this working. Is there anything else i need? What version of JQuery you using?Where in the masterpage do you add this? I’ve tried in a few places and i still get a Form is undefined error. Any suggestions? Thanks

  3. Ahaa มัน ดี การสนทนา เกี่ยวกับ โพสต์ สถานที่แห่งนี้
    ที่ นี้ เว็บไซต์ ฉันได้อ่าน ทุก ที่ดังนั้น ตอนนี้ ฉัน ยัง แสดงความคิดเห็น ที่นี่
    .

  4. Benicio Galvez says:

    I’m going to try this which sounds like a really sensible solution. I would elaborate on this: in the default master page you need to encase the above code inside a javascript wrapper, and additionally it needs to have a javascript call to jquery. The above code if simply “pasted” in the master page won’t work until it is linked to the jQuery library.

  5. Saani says:

    hi I tried this it didn’t work for me please help me in this i have pasted the code change the GUID and given the Jquery link 2.1.4 but still the check box is checked please help !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s