Error processing SSI file
LEADTOOLS Leadtools.Documents (Leadtools.Documents assembly)

UploadFile Method

Show in webframe
Example 
The JavaScript File object representing the file to upload.
Uploads a new document to the server.
Syntax
 function Leadtools.Documents.DocumentFactory.uploadFile( 
   file 
)

Parameters

ParameterTypeDescription
fileobjectThe JavaScript File object representing the file to upload.

Return Value

TypeDescription
jQueryApi.IDeferred A Promise object that may resolve succesfully to a special uri pointing to the location of the newly-created Document in the cache (verifiable with IsUploadDocumentUri). The returned Promise has a unique type of AbortableJQueryPromise that holds a Abort method.
Remarks

The UploadFile method is an abstraction of three other methods used together to manage the upload of a resource - BeginUpload, UploadDocument, and AbortUploadDocument. UploadFile wraps together the functionality of these three methods, and returns a url to the uploaded resource when the Promise resolves. This url can be used to load the document with LoadFromUri.

The Promise for this method can receive progress events. Refer to DocumentUploadProgress for more information.

The Promise object that is returned immediately by calling UploadFile is of type AbortableJQueryPromise, an extension of the usual jQuery Promise object. This class adds an additional method, Abort, which has the same functionality as AbortUploadDocument but is not static and thus does not need the uri of the uploading file. If the upload is aborted, the fail callback to the Promise object will be called with all three parameters as null. See Promises for more information.

This method uses the JavaScript File object to obtain access to a file on the local machine. Please note that the browser must support the FileReader API in order to manipulate filesystem data on the local machine. If the FileReader API is not supported, an error will be thrown and IsBrowserError will return true.

Refer to Uploading Using the Documents Library for detailed information on how to use this method and the various options used.

Example
function uploadFileExample() {
   // Assume "file" is an HTML file object in the page
   // Assume "upload" is a button on the HTML
   $("#upload").bind("click", function () {
      // Get the File object to upload
      var file = $("#file").get()[0].files[0];
      // Upload it
      console.log("Uploading ...");
      lt.Documents.DocumentFactory.uploadFile(file)
          .done(function (uri) {
             // Done, now load it
             console.log("Finished, loading");
             lt.Documents.DocumentFactory.loadFromUri(uri, null)
               .done(function (document) {
                  console.log("Document was loaded succesfully");
                  console.log("MIMEType is " + document.mimeType);
                  console.log("Number of Pages is " + document.pages.length);
               });
          });
   });
}
See Also

Reference

DocumentFactory Object
DocumentFactory Members

Error processing SSI file