CodeIgniter Forums
Problem with mime_in only for heavy image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Problem with mime_in only for heavy image (/showthread.php?tid=79064)



Problem with mime_in only for heavy image - sfarzoso - 04-16-2021

I have this input:

PHP Code:
<input type="file" class="d-none" id="featuredImage" accept=".png, .jpg, .jpeg" name="meta[featured_image]"

I set the following validation rule:

PHP Code:
'meta.featured_image'   => 'mime_in[meta.featured_image,image/png,image/jpg,image/jpeg]|max_size[meta.featured_image,1024]' 

if I upload an image of 5kb all works well, but when I try to upload an image of 3.2Mb I get:

The filetype you are attempting to upload is not allowed.

if I inspect the file heavy image using:


PHP Code:
var_dump($this->request->getFile('meta.featured_image')->getMimeType()); 


I get "directory", but it's a .jpeg (I have attached the image that causing the issue on this post).
If instead I upload the image of 5Kb and print getMimeType() I get: "image/png"

I'm running the application over nginx and php-fpm, and I set client_max_body_size 100M; inside location directive of nginx, but I don't think is this the problem.

Any idea?



RE: Problem with mime_in only for heavy image - InsiteFX - 04-16-2021

max_post_size and max_upload_size need to also be set to the save value.