Welcome Guest, Not a member yet? Register   Sign In
I need help when I try to upload an image
#1

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
Reply
#2

Remove the avatar, it is not an image type.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 05-16-2021, 10:16 PM by Secux.)

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB