Allow user to change avatar on their 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
Posted in OctoberCMS on Sep 05, 2016