I want a script in javascript that can upload a document to the document library.

I know that HTML5 Browsers can do this with ease because I can simply use the FileReader API but how do I do this for older non HTML5 browsers?

  • This require FileReader API which I have and already works but what of browsers without HTML5 support like ie9 downwards Nov 12, 2014 at 7:34

2 Answers 2


You can use jQuery widget for do this.


This plugin uses SPServices

    listName:       "Shared Documents",
    onPageChange:   function(ev){

        // If we're done with the upload, then continue to show the
        // overlay, and fade out the area that contained the upload control.
        if (ev.state == 3 && ev.isUploadDone) {
            ev.hideOverlay = false;
            $('<div style="padding: 1em; width: 80%; margin: 3em auto;" class="ui-state-highlight">Upload Successful!!!</div>')
                .fadeOut(4000, function(){

            // Reload files into viewing area.

        // If file was uploaded, but we have required fields to fill out,
        // then adjust page to only show that...
        } else if (ev.state == 3) {

                    .css("display", "none")

    }//end: onPageChange()
  • @knox2 can you close this thread by marking answer. Nov 17, 2014 at 13:44

Due to security concerns, you cannot access the file system from JavaScript; you can only perform web related activities (at least when ran from a web browser).

From the JavaScript Wikipedia article:

JavaScript and the DOM provide the potential for malicious authors to deliver scripts to run on a client computer via the web. Browser authors contain this risk using two restrictions. First, scripts run in a sandbox in which they can only perform web-related actions, not general-purpose programming tasks like creating files.

Your only options in Office 365 are to use a provider hosted app and CSOM, or to use a flash-based tool such as Uploadify.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.