1

Is there a possibility to customize upload.aspx in SharePoint online.

If yes, Please let me know how to do it?

Thanks

2

Yes, it is possible to customize. (Just don't get too excited, and keep on reading!)

It is for example possible to:

However it is not recommended to modify the upload.aspx. Upload.aspx is used in everywhere of your site collection and is also a subject of possible updates, which could in the worst case break the upload.aspx's functionality, if not only override the done changes. Basically customizing upload.aspx requires a hack'ish approach which would set your environment to unsupported state from Microsoft's point-of-view.

Now that the warnings have been given, I understand that the second link technically doesn't modify the upload.aspx and it offers a customized action in a limited context. But I will give the responsibility to you whether you wish to give it a shot!

| improve this answer | |
  • But in Sharepoint online layouts folder is maintained by microsoft how can we edit Upload form if there is no Layouts folder??? – rrr Jun 15 '17 at 18:54
  • The first link shows a way where you only "inject" JS to the upload.aspx once it's open, so no problems there. The rely on the second, you indeed can't use a copy of the upload.aspx. Instead, you would be required a create a new page with SPD and handle the upload with e.g. JS client object model, jQuery, or REST. There are examples of this. – moe Jun 15 '17 at 19:22
1

I think the correct answer is Yes, you can, but...

Indeed you can edit it but I do not recommend it, since it is one for every library. It means the changes reflect on the upload.aspx of all libraries present in your farm.

As written as a comment of @moe, I suggest to create a new page and use CSOM to save the file. Here is the code I use:

var input = document.getElementById('theInputElemenetTypeFile');
if (input.files[0]) {

    SP.SOD.executeOrDelayUntilScriptLoaded(function(){
        var ctx = SP.ClientContext.get_current();
        var web = ctx.get_web();
        var list = web.get_lists().getById("Put the list guid here");

        var fileContent = input.files[0];
        var filename = "Put the filename here";

        var fci = new SP.FileCreationInformation();
        fci.set_url(filename); // set the filename
        fci.set_overwrite(true); // flag to overwrite a already existing file
        fci.set_content(new SP.Base64EncodedByteArray());

        // copy the file to the CSOM stream
        for (var i = 0; i < fileContent.length; i++) {
            fileCreateInfo.get_content().append(fileContent.charCodeAt(i));
        }

        // add the file
        var file = list.get_rootFolder().get_files().add(fci);

        // get the related listItem in order to add properties
        var item = file.get_listItemAllFields();

        // if needed add properties
        item.set_item("Property1", "bla bla");
        item.set_item("Title", filename);
        item.set_item("Property2", "bla bla bla");

        item.update();
        list.update();

        ctx.executeQueryAsync(function() { 

            // Do what to so when successful, I refresh the page...
            window.location.reload(true);

        }, function(request, error) { 
            // In case of an error...
            var msg = SP.UI.Status.addStatus("Nachricht:", "An error has occurred.");
            SP.UI.Status.setStatusPriColor(msg, 'red');
            if (console && console.error){
                console.error(error);
            }
        })
    }, 'SP.js')
}
| improve this answer | |

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.