CodeIgniter Forums
I need help when I try to upload an 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: I need help when I try to upload an image (/showthread.php?tid=79238)



I need help when I try to upload an image - Secux - 05-16-2021

I get this error and I don't understand why 

Code:
avatar is not a valid uploaded file.

my code in controller
rules:
Code:
'avatar' => [
                'rules' => 'required|uploaded[avatar]|max_size[avatar,1024]|ext_in[avatar,jpg,jpeg,png]',

                'errors' => [
                    'required' => lang('Core.Auth.Error.required'),
                    ]
            ],

upload:
Code:
if (!$this->validate($rules)) {
            $data['validation'] = $this->validator;
        } else {

                $avatar = $this->request->getFile('avatar');
                   $newName = $avatar->getRandomName();
                   $avatar->move(WRITEPATH.'uploads', $newName);
                   $filepath = base_url()."/selfie/".$newName;

my php.ini
upload_max_filesize = 1G
post_max_size = 1G
memory_limit = 1G


RE: I need help when I try to upload an image - InsiteFX - 05-16-2021

Remove the avatar, it is not an image type.


RE: I need help when I try to upload an image - Secux - 05-16-2021

(05-16-2021, 03:36 PM)InsiteFX Wrote: Remove the avatar, it is not an image

ext_in[field_name,png,jpg,gif]

It was a problem - form enctype="multipart/form-data"
it must also be added to the instructions