Hi --
You can do it with Appery.io.
So if you want to send file content into user collection you should:
Create in form textarea field. And map it into useravatar DB field.
Add "select file" button as it described in tutorial: http://docs.appery.io/tutorials/uploa...
Change reader code from:
pre
var reader = new FileReader();
reader.onloadend = function(e) {
var fileContent = $('[name=fileContent]');
fileContent.text(e.target.result);
};
reader.readAsText(file);
/pre
to
pre
var reader = new FileReader();
reader.onloadend = function(e) {
Code: Select all
//Getting base64 string
var base64String = e.target.result;
//Setting base64 as asset for image. (you can even see selected image immediatly in your UI).
Appery("image_result").attr("src", base64String);
//Settings content of file to your textArea.
Appery("yourTextArea").val(base64String);
};
//This is function used by you. Comment it.
//reader.readAsText(file);
Code: Select all
//You should use this one.
reader.readAsDataURL(file);
/pre
That's all.