[ACCEPTED]-Rails file upload size limit-mod-rails
Accepted answer
Or if you're using nginx with passenger, add 1 in the server block:
server {
client_max_body_size 100M;
}
http://wiki.nginx.org/NginxHttpCoreModule#client_max_body_size
You may cap the upload size via Apache using 1 the LimitRequestBody directive:
<Directory "/var/www">
LimitRequestBody 1024
</Directory>
http://httpd.apache.org/docs/1.3/mod/core.html#limitrequestbody
You can use following javascript to notify 6 user that the selected file exceeds maximum 5 limit. But still its essential to have server 4 side validation.
$('#id_of_input_file_field').change(function() {
if(this.files[0].size > MAX_LIMIT_FOR_FILE){
$('#id_of_input_file_field').val('');
alert('File exceeds maximum size limit ')
}
});
MAX_LIMIT_FOR_FILE is in 3 byte so if you want set max limit of 1Mb 2 then value of MAX_LIMIT_FOR_FILE should 1 be 1048576
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.