1

I am using HTML/Jquery form to upload files to upload file in sharepoint but if filesize is big(100MB+) then chrome browser is crashed

(chrome

Aw, Snap!" something went wrong)

No error in the console.

Below is the code that i have taken from here, Browser is crashed as soon as POST method is sent from addFileToFolder is called

// Add the file to the file collection in the Shared Documents folder.
    function addFileToFolder(arrayBuffer) {

        // Get the file name from the file input control on the page.
        var parts = fileInput[0].value.split('\\');
        _Docdisplayname = parts[parts.length - 1]; // fileName = parts[parts.length - 1];  //Change the docuemnt in between the workflow

        //Update the Control to update back the list item when commit 

        $('#Docdisplayname').val(_Docdisplayname);

        // Construct the endpoint.
        var fileCollectionEndpoint = String.format(
            "{0}/_api/web/getfolderbyserverrelativeurl('{1}')/files" +
            "/add(overwrite=true, url='{2}')",
            siteUrl, Sourcelist, fileName != '' ? fileName : _Docname);

        // Send the request and return the response.
        // This call returns the SharePoint file.
        var _length = (arrayBuffer.byteLength == undefined ? arrayBuffer.length : arrayBuffer.byteLength);

        return jQuery.ajax({
            url: fileCollectionEndpoint,
            type: "POST",
            data: arrayBuffer,
            processData: false,
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
                "content-length": _length
            }
        });
    }




    // Add the file to the SharePoint folder.
                    var addFile = addFileToFolder(arrayBuffer);
                    addFile.done(function (file, status, xhr)

 {

                    // Get the list item that corresponds to the uploaded file.
                    var getItem = getListItem(file.d.ListItemAllFields.__deferred.uri);
                    getItem.done(function (listItem, status, xhr) {

                        // Change the display name and title of the list item.
                        var changeItem = updateListItem(listItem.d.ID, Sourcelist, _IsNewActivity);
                        changeItem.done(function (data, status, xhr) {

                           //success

                        });
                        changeItem.fail(onError);
                    });
                    getItem.fail(onError);
                });
                addFile.fail(onError);
            });
            getFile.fail(onError);

0

Your Answer

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