Is it possible to develop HTML5/JavaScript/Jquery/REST code to upload a file to SPO 2013 Document Library?
If so, is it possible to do some validation, error handling and business rules? For example:
If so, is it possible to do all of this with NAPA?
I found this:
Yes, I'm actually doing that right now (uploading images to a document library - and changing property values of that document once its been successfully uploaded) I found this link very useful:
http://technet.microsoft.com/en-us/dn769086(v=office.12)
I had an issue with the "fileCollectionEndPoint" and the "serverRelativeUrlToFolder" variables, I changed the value to:
var serverRelativeUrlToFolder = 'YOUR_DOCUMENT_LIBRARY';
var fileCollectionEndPoint = String.format("../../_api/web/getfolderbyserverrelativeurl('{0}')/files/add(overwrite=true, url='{1}')?@target='{2}'", serverRelativeUrlToFolder, fileName, _hostweburl);
That's just what worked for me - YMMV, the TechNet code may work OOB for you.
Handling the restriction of filetypes... you can use a client side method of checking the value of the file input element and checking against an array of extension that are acceptable... Here is a fiddle:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.