Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

How can I have the user upload their own photo and have that photo stored on the database so that each user can have his

Hi Yurri,

Thanks for your help.
I had a look at the link but I'm still a little stuck and not sure where to start.

can you give me a few steps to implement this?

Thank you
Joe

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

How can I have the user upload their own photo and have that photo stored on the database so that each user can have his

I'm going to post this as a separate thread as it is a separate question

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I have the user upload their own photo and have that photo stored on the database so that each user can have his

Hi Joe,

Here is JS code how you can get image from first image, resize it and then put it source into another component:

precode

//Get img component. You should replace "mobileimage_1" with your img component name.
var img = Apperyio("mobileimage_152");

var width = img.width();
var height = img.height();

var newWidth = 30;
var newHeight = height / newWidth * width;

var canvas = jQuery('<canvas width="' + newWidth + '" height="' + newHeight + '"></canvas>');

var c = canvas[0];
var ctx = c&#46;getContext("2d");

ctx&#46;drawImage(img[0], 0, 0, newWidth, newHeight);

&#47;&#47;Get base64String&#46;
var base64String = c&#46;toDataURL();

&#47;&#47;Using base64String&#46;
console&#46;log(base64String);
&#47;&#47;alert(base64String);

&#47;&#47;Set this picture to other image component to be sure picture is ok&#46;
Apperyio("mobileimage_154")&#46;attr("src", base64String);

/code/pre

Regards.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

How can I have the user upload their own photo and have that photo stored on the database so that each user can have his

Thank you Yurii this really helped, sorry for my late response to this.

Return to “Issues”