Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

Can someone please provide me with a step-by-step instruction on how to do this?

Any help would be appreciated!

Thank you!

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

I'd also like the user to be able to update the Bio from the app.

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

How can I have a user upload their own "Bio" and have that stored in the database?

Hi Stefan.

Please follow these steps:

1 Add HTML component on the page. And populate it with following code: http://prntscr.com/3p4f65/direct

precode

<form enctype="multipart/form-data" method="post" name="fileinfo" style="visibility:hidden">
<fieldset>
<input type ="file" name ="fileselect" id="fileselect">
</fieldset>
</form>
<script type="text/javascript">
&#47;&#47; set event listener for call preview after select file
var fileselect = $('#fileselect');
fileselect&#46;bind("change", fileSelectHandler);
</script>

/code/pre

2 Add Button with text "Choose file".

3 Add JS event handler on "click" event to this button. Populate with following code:

precode

$('#fileselect')&#46;trigger('click');

/code/pre

4 Add new JS asset and populate it with following code: http://prntscr.com/3p4ji1/direct

precode

var file;

function fileSelectHandler(e) {
var files = e&#46;target&#46;files || e&#46;dataTransfer&#46;files;
file = files[0];
previewFile();
}

function previewFile() {

Code: Select all

 var previewContainer = $('table[dsid=preview]'); 
 var fileName = $('[name=fileName]'); 
 var fileContentType = $('[name=fileContentType]'); 
 &#47;&#47; make the preview container visible once a file was selected 
 previewContainer&#46;toggle(); 

 &#47;&#47; set the file name 
 fileName&#46;text(file&#46;name); 
 fileContentType&#46;text(file&#46;type); 

 var reader = new FileReader(); 
 reader&#46;onloadend = function(e) { 
     var fileDataUrl = e&#46;target&#46;result; 

     localStorage&#46;setItem("fileDataUrl", fileDataUrl); 
 }; 
 &#47;&#47;reader&#46;readAsText(file); 
 &#47;&#47;reader&#46;readAsBinaryString(file); 
 &#47;&#47;reader&#46;readAsArrayBuffer(file); 
 reader&#46;readAsDataURL(file); 

}

/code/pre

5 Then you can access file raw source with following code:

precode

&#47;&#47;Set file to image component
Apperyio("imgcomponentName")&#46;attr("src", localStorage&#46;getItem("fileDataUrl"));

&#47;&#47;Log out to console file content
console&#46;log(localStorage&#46;getItem("fileDataUrl"));

/code/pre

So you have file source in the "fileDataUrl" LSV. From this time you can store it in DB. Or assign to image component as shown in prep step.

That's all.

Regards.

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

Thanks again for the help. I'm sorry I should have been more clear.

I would like the user to be able to do this:

1) click the "update" button above "Bio"

2) Have a pop-up window appear that allows the user to enter their new Bio information

3) User clicks the "Update Bio" button in the pop-up

4) Pop-up goes away, the users "Bio" section reflects what they typed in, and their "bio" information is stored to the database.

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

How can I have a user upload their own "Bio" and have that stored in the database?

Stefan.

You described in details this processing.

So i guess there is no problem to implement it.

Did you tried some so far?

Please try to start if you don't done it before and tell us if you have any problem/question. We will help.

Thanks and regards.

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

I have tried to do this multiple times but can not get the user entered data to replace the label under the "bio" label. Any ideas as to how I might do this and the store it into the database?

Thank you so much!

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

Hi Yurii, So I have created a pop-up window that stores the entered information to a variable called "bioentry"
Image

I have also created a new column in the DB called "Bio"
Image

Now that I have this, I then used the DB User_Info_Update_Service and assigned named it to "BioUpdate"
Image

So where do I go from here? I cannot seem to find a way to assign the "bioentry" to the label while having it stored in the DB. Can you please help me with this? Thank you so much!

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

UPDATE:

I have had the "Update" button above the "Bio" label invoke restservice1
Image

Then when restservice1 is successful it runs the following JS code..
Image

I have also connected the "Bio" component to the "bioentry" label to display the user inputted text.
Image

HOWEVER this does not work and the label shows "undefined" after the user submits text through the pop-up window

Any ideas why?

Stefan Zier
Posts: 0
Joined: Sun Jun 01, 2014 7:22 pm

How can I have a user upload their own "Bio" and have that stored in the database?

Hi Yurii,

I am still stuck here and would appreciate if you could help me because no matter what changes I make or service I use, I cannot seem to save the user entered data to the DB collection and have the label reflect what was entered into to the prompt.

Thank you again!

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

How can I have a user upload their own "Bio" and have that stored in the database?

Hi Stefan.

Please provide us your app public link.

And describe whole use case how you want it to work.

I will provide you instructions how to get it work after.

Thanks.

Return to “Issues”