问题
I have developed a SharePoint App that is running on Online SharePoint 2016 site Collection.
Have another Software Application with Rest API that is running on my another Online server. More this app is purely developed using HTML,Javascript/JQuery. no server side scripting.
More SharePoint App strongly integrated with my Software Application (using Ajax calls for data fetching).
Now the issue is, i want to upload files into SharePoint from Software Application.
Note: Anonymous access is not available in Office 365 Online account as per my R&D.
Please help and Thanks in Advance.
回答1:
You can follow the steps below to upload a file by using the REST API and jQuery:
- Convert the local file to an array buffer by using the FileReader API, which requires HTML5 support. The jQuery(document).ready function check FileReader API support in the browser.
- Add the file to the Shared Documents folder by using the Add method on the folder's file collection. The array buffer is passed in the body of the POST request.
- Get the list item that correspond to uploaded file by using the ListItemAllFields property of uploaded file.
- Change the display name and title of the list item by using a MERGE request.
These examples use the getfolderbyserverrelativeurl endpoint to reach the file collection. You can also use a list endpoint (example: …/_api/web/lists/getbytitle('')/rootfolder/files/add).
For more information, please review the following link: Upload a file by using the REST API and jQuery
来源:https://stackoverflow.com/questions/52057747/upload-document-in-online-sharepoint-site-collection-document-library-from-anoth