1

I'm using Codeigniter, i have a problem when uploading too large images, i.e. the size of the image is larger than upload_max_filesize in the server.

I would like to show a custom message for the user instead of this message:

Warning: POST Content-Length of 36276449 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
The action you have requested is not allowed.

melwil
  • 2,547
  • 1
  • 19
  • 34

2 Answers2

0

You have to validate, while uploading image to the server, if the image size is below some MB then allow to upload on the server otherwise throw the validation error.

You can use jQuery validate plugin to do that here is the reference you can use it. Validate file extension and size before submitting form

Aman
  • 19
  • 2
0

Maybe (if you are the server admin) you can increase the maximun post size (Increasing the maximum post size) and then check the size and show the message through codeigniter:

$config['max_size']             = 100;
...
$this->load->library('upload', $config);

if (!$this->upload->do_upload('userfile'))
{
    //handle the error with $this->upload->display_errors()
}
cesar.mi
  • 111
  • 1
  • 4