Technical notes about OctoberCMS a Laravel CMS. Notes are written by inetis team, a Swiss webagency

<- Back

Allow user to change avatar on their profile page

Posted on by

Use the nesti-uploader plugin to allow your user to change their avatar from the profile page.

Install the netsti-uploader to add the upload feature in frontend for OctoberCMS.

Add the component to the profile page

{% component 'imageUploader' %}

and configure the model. We will match the "avatar" field of the Rainlab User plugin

For the last operation, extend the Rainlab/User model in the "Code" tab of the page.

function onInit()
{
    $user = Auth::getUser();
    if($user){
        $component = $this->addComponent(
            'NetSTI\Uploader\Components\ImageUploader',
            'imageUploader',
            ['modelClass'=>'RainLab\User\Models\User','modelKeyColumn'=>'avatar', 'deferredBinding' => false]
        );

        $component->bindModel('avatar', $user);
    }
}

Thanks to iocare

source: https://octobercms.com/forum/post/frontend-file-upload?page=2