Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Save Member Image uploaded from front end


Go to End


784 Views

Avatar
pinkal

Community Member, 3 Posts

9 October 2014 at 9:14pm

Edited: 09/10/2014 9:16pm

Hello Guys, I am creating profile edit form in front end, with Image upload field. Some design requirements stopped me from using Uploadfield as I am not very good at silverstripe. I am able to get up to following function i.e. I am receiving image in $data variable and can access it with $data['mf_file_dragndrop']. but I don't know how to handle uploaded image and update Member image. Can any one please help.

public function MemberImage($data){

$member = TeamMember::currentUser();
$up =new Upload();
$bUploadNew = false;

if (!empty($data['mf_file_dragndrop']['name']))
$bUploadNew = true;

if ($bUploadNew) {
$img = Object::create('Image');
$up->loadIntoFile($data['mf_file_dragndrop'], $img, 'Uploads');
//to do
// update member with new image and return image path so in profile new image can be displayed
}
}