SP.File.startUpload Method (sp.js)

Starts a new chunk upload session and uploads the first fragment.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

Starts a new chunk upload session and uploads the first fragment. The current file content is not changed when this method completes. The method is idempotent (and therefore does not change the result) as long as you use the same values for uploadId and stream.The upload session ends either when you use the SP.File.cancelUpload Method (sp.js) method or when you successfully complete the upload session by passing the rest of the file contents through the SP.File.continueUpload Method (sp.js) and SP.File.finishUpload Method (sp.js) methods.

For example, you can pass a 35 MB file by dividing it into three 10 MB streams and one 5 MB stream and uploading them this way (using the resulting offset values of 10, 20 and 30 MB):

startUpload(GUID, stream1)
continueUpload(GUID, 10 MB, stream2)
continueUpload(GUID, 20 MB, stream3)
finishUpload(GUID, 30 MB, stream4)

The startUpload and SP.File.cancelUpload Method (sp.js) methods return the size of the running total of uploaded data in bytes, so you can pass those return values to subsequent uses of SP.File.cancelUpload Method (sp.js) and SP.File.finishUpload Method (sp.js).

This method is currently available only on Office 365.

SP.File.startUpload()

Parameters

Return value

Type: Number

The size of the uploaded data in bytes.