Uploading Documents to SP 2013 with jQuery and REST work just fine (Properties when uploading Files using REST in SP 2013) but these methods require a HTML5 compatible browser. The problem is now I also have to target older browsers.

I found a nice jQuery Plugin (https://github.com/blueimp/jQuery-File-Upload) which looks very promising and should do the job. e.g. wrapping in an iframe for older browsers. So I configured it the same as previously but it does not work. I guess you have to provide data as a base64 encoded arraybuffer when using REST. Is there a way to upload a file (can also be witouth REST) to a DocLib, ideally with this plugin?


function initializeUploader() {
    // Init Uploader
        dataType: 'json',
        url: getRESTUrl(),

        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()

        add: function (e, data) {
            data.context = $('#SubmitButton').val('Start Upload')
                .click(function () {
                    //url = getRESTUrl();
                    data.context = $('<p/>').text('Uploading...').replaceAll($(this));

        done: function (e, data) {
            data.context.text("upload finished");

        fail: function (e, data) {
            data.context.text("upload failed");

function getRESTUrl() {
    var serverurl = SPWeb.get_serverRelativeUrl() + "/Lists/TestDocLib";
    var targetRESTUrl = _spPageContextInfo.webServerRelativeUrl +
                        "/_api/web/GetFolderByServerRelativeUrl('" + serverurl + "')/Files" +
    return targetRESTUrl;

Errors I receive in the LOGS:

SPRequest.PutFile: UserPrincipalName=[...], AppPrincipalName= ,bstrUrl=http://{myweb} ,bstrWebRelativeUrl=Lists/TestDocLib/testfile.png ,cbFile=38862 ,punkSPFileMgr= ,punkFFM= ,PutFileOpt=1 [...]

System.IO.DirectoryNotFoundException: 0x80070003There is no file with URL 'http://{site}/Lists/TestDocLib/testfile.png' in this Web., StackTrace:

I don't know why SP (obivously) wants to retrieve the file. Previously I also had to specify the target filename and it just worked fine.

2 Answers 2


I have built a jQuery library that includes a file upload widget. I have tested it in SP 2007, 2010 and 2013 and its been working great. See project site here: http://purtuga.github.io/SPWidgets/

The widget you want to look at is SPControlUpload.

The project has a quick SPA demo page that you can upload to a document library and quickly play with all widgets provided.

  • Thank you that looks very interesting. I will try it out on Monday. Until then... is there a way to specify the target filename?
    – Kirschi
    Oct 5, 2013 at 19:15
  • No, you can't specify a target file. But once uploaded you can use one of the API's to Change the file name.
    – Paul T.
    Oct 6, 2013 at 0:58
  • Ok but this will leave me with the problem that, if I specify overwrite=false, the user will get a error message if the file already exists? With REST this was possible. This will only leave me with a temporary Doc Lib which performs checks and renames the file in an EventReceiver before copying it to the final Doc Lib I guess?
    – Kirschi
    Oct 6, 2013 at 8:11
  • Correct. Setting overwrite to false will give you an error if the file already exists. There are ways to copy a file from one document library to another. I don't know about REST but WebServices has copy operations.
    – Paul T.
    Oct 6, 2013 at 12:18

Your server relative URL is wrong. Libraries are not found at <site url>/lists/<library>, but rather <site url>/<library>. So just remove /lists from your url, and it should work.

  • I don't know about SP Online but my lists are always under /Lists/. At least if they are deployed with Visual Studio. Also this was not the problem back then.
    – Kirschi
    Jun 2, 2014 at 6:45

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.