

The second example makes same-domain calls, like a SharePoint-hosted add-in would do when uploading files to the add-in web, or a solution that's running on the server would do when uploading files. The first example uses SP.AppContextSite to make calls across SharePoint domains, like a SharePoint-hosted add-in would do when uploading files to the host web. Get the list item that corresponds to the uploaded file by using the ListItemAllFields property of the uploaded file.Ĭhange the display name and title of the list item by using a MERGE request.īoth code examples in this article use the REST API and jQuery AJAX requests to upload a file to the Shared Documents folder and then change list item properties. These examples use the getfolderbyserverrelativeurl endpoint to reach the file collection, but you can also use a list endpoint (example: The array buffer is passed in the body of the POST request. The jQuery(document).ready function checks for FileReader API support in the browser.Īdd the file to the Shared Documents folder by using the Add method on the folder's file collection.

This process uses the following high-level steps:Ĭonvert the local file to an array buffer by using the FileReader API, which requires HTML5 support. The code examples in this article use the REST interface and jQuery AJAX requests to add a local file to the Documents library, and then change properties of the list item that represents the uploaded file.
