Default user avatar within create

Hey,

I’m using the users create function for a registration page and I was wondering, is there a way to set an avatar with this function as well? I thought I could use an URL to an image in assets/images, but didn’t seem to work.

Thanks!

This thread might help: Is it possible to upload avatar from front-end?

Edit: the whole point here is that the image must be stored in the avatars folder and it must have the same filename as the username. You can’t just link to any other image. However, you could copy a default image from any folder to the avatars folder and rename it in the process.

Thanks,

Been trying this for a while now, and still no results. This is the upload code within the controller. It doesn’t do anything :frowning:
Also, note that I’m over the default avatars and in turn I’m making the avatar mandatory.

if (isset($_FILES['avatar']['name']))
                {
                    $ext = strtolower(pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION));
                    $filename = implode('.', array(get('username'), $ext));

                    $upload = new Upload(kirby()->urls()->assets() . DS . 'avatars' . DS . $filename, array(
                        'input'     => 'avatar',
                        'overwrite' => true
                    ));
                } 

Is there something I’m doing wrong?

For example I’ve used this in my controller and nothing happens. No error or anything, but nothing gets uploaded :frowning:

Could you please post your form together with your complete controller for testing?

Hey, I finally come to a fix. Weren’t doing everything right, but it’s fixed now. Thanks!