Reputation: 10366
To start off, I've set my post_max_size
in /etc/php.ini
to 4M just as a test. I have a check in place to check for file type and size of file. I want to only accept JPG, GIF and PNG. The file size cannot be larger than 4M. It seems that if the file size is larger than what's set in post_max_size
, my code won't throw an error. If I set my PHP to deny uploads larger than let's say 2M but less than 4M, it'll throw an error (what i want). I believe this is due to PHP not accepting anything over 4M.
if (is_uploaded_file($_FILES["file"]["tmp_name"]))
{
$file_type = exif_imagetype($_FILES["file"]["tmp_name"]);
} else {
$this->form_validation->set_message('valid_image', 'Error uploading file!!!');
return false;
}
Upvotes: 0
Views: 4918
Reputation: 958
Not sure, but I would check for file size on the client before the upload happens. This approach would upload the whole file to the server first before giving the error even if it worked.
Upvotes: 0
Reputation: 655129
Use the value in $_FILES["file"]["error"]
to check the upload status.
Upvotes: 1
Reputation: 1908
There is another ini flag upload_max_filesize that you should increase to your new limit as well
Upvotes: 1