Welcome Guest, Not a member yet? Register   Sign In
Validation rules of file
#1

HI , i have a problem with a file validation rule :
this is my file in form :


Code:
                        <input type="file" name="immagine_logo" class="form-control-file">

Code:
                                    'immagine_logo' => [         
                                                'rules'=>'is_image[immagine_logo]|max_size[immagine_logo,10000]|ext_in[immagine_logo,jpg,jpeg,gif,png,webp]',
                                                'errors'=>[
                                                        'is_image'=>'Logo non è un immagine', 
                                                        'ext_in'=>'Formato supportato : jpg,jpeg,gif,png.webp',
                                                        'max_size'=>'Immagine troppo pesante massimo 3MB'
                                                      ]
                                                ]




and this the dd of file 

Code:
$_FILES array (1)
⇄⧉immagine_logo => array (6)
⇄name => string (17) "1665231204339.jpg"
⇄full_path => string (17) "1665231204339.jpg"
⇄type => string (0) ""
⇄tmp_name => string (0) ""
⇄error => integer 1
⇄size => integer 0

The error is :  immagine troppo pesante massimo 3MB if i move max_size after ext_in i have the other error:  Formato supportato : jpg,jpeg,gif,png.webp

Which is the error ?
Reply
#2

The file exceeds 3 MB - there may be a limitation in PHP. Edited in php.ini
Reply
#3

(This post was last modified: 10-11-2022, 11:00 AM by pippuccio76.)

(10-11-2022, 10:48 AM)ozornick Wrote: The file exceeds 3 MB - there may be a limitation in PHP. Edited in php.ini
no if i move ext_in after max_size have the ext_in error....
Reply
#4

(This post was last modified: 10-11-2022, 02:08 PM by ozornick.)

tmp_name empty. File not uploaded to server. May be there problem? Check writable folder on access "chmod 777"
Reply
#5

In your $_FILES array, when you upload the image, the error code is 1, which means "UPLOAD_ERR_INI_SIZE". This means the uploaded file exceeds the upload_max_filesize directive in php.ini. Update that otherwise "max_size" will fail.

On "ext_in" error, since the file was not uploaded because of the size problem, the validator cannot check the extension since the file is missing. Thus, it errors.
Reply
#6

php.ini

post_max_size = 256M
upload_max_filesize = 256M
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB