I have an issue with uploading file > 2MB. I have used javascript code to upload files from my UI. In Central Admin, the allowed file size has been increased to 10MB.

Whenever I try to upload a file > 2MB, its not allowing me.

Throws the following error:


"The request message is too big. The server does not allow messages larger than 2097152 bytes."

Please suggest.


3 Answers 3


There are a couple of places that you need to change this on, You have done central admin but you also need to do web application web.config:

search for httpRuntime and update to this:

<httpRuntime executionTimeout="999999" maxRequestLength="5120" requestValidationMode="2.0" /> 

above allows only 5mb max, to increase the number:


mb * 1024 = total bytes;

example i want to increase it to 28 MB than i would do: 28 * 1024 = 28672


Th following approaches are commonly used when uploading files via SharePoint CSOM/JSOM

FileCollection.Add method

FileCollection.Add method adds a file to the collection based on provided file creation information.

CSOM Example:

public static void UploadFile(string filePath,ClientContext context, string listTitle)
    var fileInfo = new FileCreationInformation
                Content = System.IO.File.ReadAllBytes(filePath),
                Url = Path.GetFileName(filePath)

    var targetList = context.Web.Lists.GetByTitle(listTitle);
    var uploadFile = targetList.RootFolder.Files.Add(fileInfo);

The above code might fail throwing a (400) Bad Request error depending on the file size.

The following code is used to set a higher received message size for the WCF service of the client object model (client.svc) using SPClientRequestServiceSettings.MaxReceivedMessageSize Property:

public static void SetMaxMessageSize(int sizeMb)
     var ws = SPWebService.ContentService;
     var clientSettings = ws.ClientRequestServiceSettings;
     clientSettings.MaxReceivedMessageSize = sizeMb*1024* 1024; 

Note: This is not the same as the max. file size upload limit option available in the web application settings.

File.SaveBinaryDirect method

File.SaveBinaryDirect method uploads the specified file to a SharePoint site without requiring an ExecuteQuery() method call.

This methods uses HTTP DAV and sends raw binary across the wire and does not increase the message size. It is also the preferred upload method when using managed client object model.

CSOM example:

private static void UploadFile(string filePath,ClientContext context, string listTitle)
    using (var fs = new FileStream(filePath, FileMode.Open))
        var list = context.Web.Lists.GetByTitle(listTitle);
        var fileName = Path.GetFileName(filePath);
        var fileUrl = String.Format("{0}/{1}", list.RootFolder.ServerRelativeUrl, fileName);
        Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, fileUrl, fs, true);
  • The above is not javascript code as the original poster was asking.
    – DiggyJohn
    Sep 26, 2016 at 12:52

I already posted this on stack overflow, so here goes...

SharePoint has its own limits for CSOM. Unfortunately, these limits cannot be configured in Central Administration and also cannot be set using CSOM for obvious reasons.

When googling for the issue, mostly a solution is given by setting the ClientRequestServiceSettings.MaxReceivedMessageSize property to the desired size.

Call the following PowerShell script from SharePoint Management Shell :

$ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 
$ws.ClientRequestServiceSettings.MaxReceivedMessageSize = 209715200 

This will set the limit to 200 MB.

However, in SharePoint 2013 Microsoft apparently added another configuration setting to also limit the amount of data which the server shall process from a CSOM request (Why anyone would configure this one differently is beyond me...). After reading a very, very long SharePoint Log file and crawling through some disassembled SharePoint server code, I found that this parameter can be set via the property ClientRequestServiceSettings.MaxParseMessageSize.

We are now using the following script with SharePoint 2013 and it works great:

$ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 
$ws.ClientRequestServiceSettings.MaxReceivedMessageSize = 209715200 
$ws.ClientRequestServiceSettings.MaxParseMessageSize = 209715200 

Hope that saves some people a headache!


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.