In my Codeigniter based code, I have taken the following measures:
MultiPHP INI Editor in Cpanel
asp_tags = Off
display_errors = Off
max_execution_time = 300
max_input_time = 600
max_input_vars = 1000
memory_limit = 512M
post_max_size = 128M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php56"
upload_max_filesize = 128M
zlib.output_compression = Off
.htaccess in Home Directory
<IfModule php5_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 20000
php_value max_input_time 20000
php_value max_input_vars 1000
php_value memory_limit 2G
php_value post_max_size 2G
php_value session.gc_maxlifetime 20000
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 2G
php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 20000
php_value max_input_time 20000
php_value max_input_vars 1000
php_value memory_limit 2G
php_value post_max_size 2G
php_value session.gc_maxlifetime 20000
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 2G
php_flag zlib.output_compression Off
</IfModule>
First lines in Controller and Model:
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
ini_set("pcre.backtrack_limit", "100000000");
ini_set("max_allowed_packet ", "2G");
ini_set("max_execution_time ", "20000");
ini_set('max_input_time','20000');
ini_set('memory_limit', '2G');
set_time_limit(0);
$config before file upload
$config=array(
'upload_path'=>$_SERVER['DOCUMENT_ROOT']."/assets/uploads/rpt/",
'allowed_types'=>"rpt",
'overwrite' => TRUE,
'max_size' => '100000000',
'file_name' =>$filename
);
$this->load->library('upload', $config);
$this->upload->initialize($config);
if($this->upload->do_upload('rpt1'))
{
// do something
}
else
{
return "<div class='alert alert-danger'>".$this->upload->display_errors()."</div>";
}
Still I am getting the below message on uploading file greater than 2 MB size:
The uploaded file exceeds the maximum allowed size in your PHP
configuration file.
What else is the solution?
2
Answers
Finally I opened the WHM to edit php INI settings. making changes there corrected the issue.
You need to set the value of
upload_max_filesize
andpost_max_size
in your php.ini :After modifying
php.ini
file(s), you need to restart your HTTP server to use new configuration.If you can’t change your
php.ini
, you’re out of luck. You cannot change these values at run-time; uploads of file larger than the value specified inphp.ini
will have failed by the time execution reaches your call toini_set
.OR
Even you can set in
.htaccess
file of project