1

When using the upload functionality in CodeIgniter, if I try to upload a pdf file that is larger than 20M, I either get a "404 file not found" or a 413 Request Entity Too Large. I can see that it is "Uploading nn%", up to about 97% or 98% and then it quits and gives me an error. If I echo phpinfo(), I can see the following:

upload_max_filesize = 64M  
post_max_size = 256M  

Also, if I use the File Manager on the cPanel, I am able to upload larger files with no problem.

I put the following in the .htaccess file (which was suggested on another question), but it hasn't helped:

<IfModule mod_php5.c>  
    php_value upload_max_filesize 128M  
    php_value post_max_size 128M  
    php_value max_input_time 3600  
    php_value max_execution_time 3600  
</IfModule>   
<IfModule mod_php4.c>  
  php_value upload_max_filesize 128M  
  php_value post_max_size 128M  
   php_value max_input_time 3600  
   php_value max_execution_time 3600  
</IfModule>   

I am fairly new to PHP.

S. Lynch
  • 31
  • 1
  • 7
  • Take a look at `memory_limit` in php.ini. It should be larger than `post_max_size`. If you have access to php.ini there is no point in using .htaccess. That method is mostly useful when you do not have access to php.ini. – DFriend Oct 13 '16 at 15:49
  • memory_limit is 512M – S. Lynch Oct 13 '16 at 19:24

1 Answers1

1

It looks like the error is coming not from PHP but from a web server.

If you're using nginx, you could up the max allowed post size with client_max_body_size directive

server {
    ...
    client_max_body_size 128m
    ...
}

If you're using Apache, then there are a couple of options to check for in its config file (httpd.conf).

LimitRequestBody 131072000

If mod_security module is used in Apache, update limit for it as well:

SecRequestBodyLimit 131072000

Don't forget to restart the server.

Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • I need to pass this info to my supervisor, so that he can update that. Hopefully, he can do that today, but I will be on vacation next week, so I might not be able to give you the results until the following week. Thanks! – S. Lynch Oct 14 '16 at 14:46
  • my supervisor has not yet tried this, but I wanted to make sure you knew that I **was** able to upload the large files via the File Manager on the cPanel, which would lead me to believe that it is not an issue with server. What do you think? – S. Lynch Oct 26 '16 at 14:46
  • This corrected the problem on Apache. Thanks @Vaviloff – S. Lynch Oct 26 '16 at 18:43
  • Sorry coudn't answer in time, but I'm pretty sure cPanel uses another server to upload files. Anyway, glad you fixed it, @S.Lynch! – Vaviloff Oct 27 '16 at 03:11