Trying to update custom customer attribute value while customer edit from frontend , and my field is file upload control but unable to save the attribute
Tried
$customer = $observer->getEvent()->getCustomer();
$customer->setCustomAttribute('profileimage', '123.jpg');
$this->customerRepository->save($customer);
but getting error Call to a member function setCustomAttribute() on null
secondly, I have also try
$event = $observer->getEvent();
$customer = $observer->getCustomerDataObject();
$customerId = $customer->getId();
$customerData = $this->_customerRepositoryInterface->getById($customerId);
$customerData->setCustomAttribute('profileimage', '123.jpg');
$customer->updateData($customerData);
$customerResource = $this->customerFactory->create();
$customerResource->saveAttribute($customer, 'profileimage');
Still getting error for updateData() function not found.
can anyone help me out to save custom customer attribute from frontend for image in Magento 2.