How to Copy files and Folders from one site to another using Jquery or Java Script in SharePoint online?

Hello SharePointers,

Here are the code to copy files from one sharepoint site to another in Office 365 environment.

function copyFile() {
var current_context = SP.ClientContext.get_current();
SP.MoveCopyUtil.copyFile(current_context,”https://my.sharepoint.com/sites/SitePages/Happy.aspx”,”https://xxx.sharepoint.com/sites/Pages/Happier.aspx”);
current_context.executeQueryAsync(function(){ PageCopySuccess(); },function(){ PageCopyFailure(); });
function PageCopySuccess(){
alert(‘Success’);
}
function PageCopyFailure(){
alert(‘Sorry, Try once again’);
}
}

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published.