Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Interesting dilemma here maybe some can weigh in on. I have a requirement to disable the "overwrite existing files" checkbox when uploading a single or multiple documents to a document library. The initial request was to hide the control completely, although I could probably see simply disabling the control.

As the document library points to the _layouts upload.aspx page, does anyone have some input on a workaround for this?

share|improve this question
add comment

8 Answers

up vote 4 down vote accepted

One method I've used to customize the upload page is to take a copy of upload.aspx and rename it to something like upload2.aspx. Keep it in the /layouts folder (or subfolder of) since it won't like being anywhere else.

Once you have the copy, you can make your modifications as you like.

The last step is to tell the upload menu items on the document library toolbars to point to the new upload page. You can do this with some jQuery, for example

$("ie\\:menuitem[text='Upload Document']").each(function(){

   $(this).attr('onMenuClick', $(this).attr('onMenuClick')
          .replace('Upload.aspx', 'Upload2.aspx'));
 });
share|improve this answer
    
Thanks for all of the feedback; the crux of the issue is that we're on a corporate server and don't have access to the _layouts folder. Yet another case where there's no simple solution; even getting them to duplicate the uploads.aspx file for me is like pulling teeth (the "but the change affects everyone" argument from people that don't understand the platform). –  webdes03 Apr 6 '10 at 15:01
    
@Paul: I've never seen the `ie\` syntax before and it looks quite interesting. What does this mean? –  Alex Angas Apr 7 '10 at 7:27
3  
@Alex: Can I assume a little knowledge of jQuery? So SharePoint's menu infrastructure generally uses the tags <menu><ie:menuitem>. The $("ie\\:menuitem") above is basically 'jQuery selector syntax' which will select each <ie:menuitem> tag with a text attribute of 'Upload Document'. –  Paul Lucas Apr 7 '10 at 14:37
    
@Paul: So the double backslash is essentially an escape character for the colon? –  Alex Angas Apr 8 '10 at 7:43
    
That's correct! :-) –  Paul Lucas Apr 8 '10 at 21:45
add comment

I've been asked to do this, too, and there's no really good answer that I've come up with. If you hack the _layouts/upload.aspx page, it'll take effect throughout the Site Collection(s) on that WFE. (And you will no longer be in a "supported state", and an upgrade will clobber it, and hair will grow out of your palms.)

You can, however, create a customized upload.aspx for a specific list by cloning the page and changing the New Document Form in Supporting Files for that list.

share|improve this answer
    
Also any changes you want to make in the LAYOUTS directory must be replicated on each web front end identically. Or hair will grow out of your palms :) –  James Love Feb 1 '12 at 20:06
add comment

Back in the WSS 2 days, couldn't you copy the contents of the LAYOUTS directory to another directory (LAYOUTS_CUSTOM). Then, in IIS, change the path of the layouts virtual directory. IIRC, this was the "least bad" unsupported state since future updates wouldn't clobber your changes and you could merge them afterwards.

share|improve this answer
    
Making changes like these is in IIS now unsupported since WSS3. –  James Love Feb 1 '12 at 20:04
add comment

You can create an Event Receiver that checks if a file already exists and cancels the operation if someone wants to overwrite an existing file.

Alternatively, use the free SharePoint Infuser to inject some JavaScript that checks if the current page is upload.aspx and then remove the check box.

share|improve this answer
add comment

When I am putting below javascript in content editor web part to change upload.aspx url, it will remove whole toolbar from the AllItems.aspx page, can you please let me know what should I need to add below to replacing upload.aspx URL?

$("ie\:menuitem[text='Upload Document']").each(function(){

$(this).attr('onMenuClick', $(this).attr('onMenuClick') .replace('Upload.aspx', 'Upload2.aspx')); });

Thanks, Sanket

share|improve this answer
    
Sanket, That will not remove the entire toolbar, it will only change the URL behind the Upload Document button. Mike –  webdes03 Aug 31 '10 at 19:16
add comment

Step 1: Download and import jquery.min.js into SPD Site Assets

Step 2: Create HideUpload.js and import it on SPD Site Assets

//HideUpload.js
//Control id captured by browsing (e.g. Upload.aspx) page from SPD

jQuery(document).ready(function ($) {

//alert('hiiiiiiii');

//var MultipleUpload = document.getElementById("ctl00_PlaceHolderMain_UploadDocumentSection_ctl03_UploadMultipleLink");
//if( MultipleUpload != null)
//{
//  alert('multiple upload inside');
//  MultipleUpload.style.display= "none";
//}
//ctl00_PlaceHolderMain_ctl04_ctl02_uploadLocation

var DestinationFolder = document.getElementById("ctl00_PlaceHolderMain_ctl04_ctl02_uploadLocation");
if( DestinationFolder != null)
{

//  alert('DestinationFolder  inside');
//  DestinationFolder.style.display= "none";
        DestinationFolder.disabled= "true";
}

var ChooseFolder = document.getElementById("ctl00_PlaceHolderMain_ctl04_ctl02_selectTargetButton");
if( ChooseFolder!= null)
{

//  alert('ChooseFolder inside');
//  DestinationFolder.style.display= "none";
        ChooseFolder.disabled= "true";
}

    //let's call the method that hides the link and pass
    //in the GUID for our Document Library we want to hide
    //the link on
    HideUploadLink("{FCC65F1A-9D9B-4AF0-8B5C-A16B2A11050B}");
});

Step 3: Checkout the used master page and paste the following just before </head> tag.

<script type="text/javascript" src="../../SiteAssets/jquery.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/HideUplaod.js"></script>
share|improve this answer
add comment

Maybe you will find my solution somehow useful - Custom upload form for document library in SharePoint 2010 - programmatic approach. It's a full programmatic server side solution, it does not require any javascript tricks, it can be applied selectively to specific Document Libraries based on custom list templates (no need to change the default behaviour on entire WFE) and it is quite simple.

On stackoverflow someone posted similar question - How do I change the upload page for a particular document library in SharePoint?

share|improve this answer
add comment

As a non-javascript alternative you could have a look at this article: Customize the SharePoint Upload Page by Russel Gove.
It is also available as installable package, see http://spcustomupload.codeplex.com.
You might need to simplify it a bit to meet your requirements.
Add for instance

this.UploadMultipleLink.Visible = false; 

to the Onload methode of your custom Upload application page which inherits from UploadPage class.
Hint: Instead of renaming a copy of Upload.aspx from the Layouts - folder (cf. article), add that copy to a custom subfolder of Layouts - folder without renaming it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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