When I'm trying to transfer a XML file to server I get this error.
In my scenario a web page processes a XML file with javascript and then upload the XML processed file to a PHP server.
The file capacity is 400K.
php.ini
post_max_size = 8M
upload_max_filesize = 2M
memory_limit = 128M
Client initial request:
$.ajax({
type: "GET",
url: "/dirname/filename.xml",
dataType: "xml",
async: false,
success: function(data){
xmlCID = data;
},
error: function(jqXHR, textStatus, errorThrown){
console.log(jqXHR.responseText, textStatus, errorThrown);
alert(textStatus);
}
});
Client upload request
$.ajax({
url: "/dirname/filename.xml",
dataType: "xml",
method: "PUT",
processData: false,
data: xmlCID,
success: function(data){
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText, textStatus, errorThrown);
}
});
Unfortunely, server response is:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>413 - Request Entity Too Large</title>
</head>
<body>
<h1>413 - Request Entity Too Large</h1>
</body>
</html>
As hakre pointed out, beyond the settings in PHP you'll often receive 413 errors occur when the size of the request payload is beyond what the web server configuration allows. These directives vary by server, but here are some common ones (if you're using a hosted platform, you'll likely need to contact your host's support team):
Nginx: Look at the client_max_body_size
directive for nginx.conf
(http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size)
Apache: The directive LimitRequestBody
can be used in httpd.conf
or in directory-level .htaccess
files (http://httpd.apache.org/docs/2.4/mod/core.html#limitrequestbody)
IIS: Look into maxAllowedContentLength
(part of requestFiltering
> requestLimits
), or UploadReadAheadSize
in IIS6 (IIS solutions are very version-dependent, so I'd recommend researching a bit).
If you're serving requests over HTTP and HTTPS, make sure that the relevant configuration applies to both.
While less common (more so in corporate networks), this can also have to do with other proxies or security devices that the request is being passed through, since each of those may have different limits affecting the handling of the request.
When in doubt, check the logs: first, make sure that the request is getting to your server (in the access logs), if it is, check the response code, and then also check the error logs.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With