Page 1 of 4

How can I convert the data from the upload of image into base64?

Posted: Fri Mar 21, 2014 11:31 pm
by adam griffin

How can I convert the data from the upload of image into base64?

The data I get from the image is something like this :

�PNG


IHDRjx ?g bKGD������� tIME � $ :� �IDATx���{�UU ǿs gx+(�HA?� ���
�ǧ���4�R�4 �4�|Pi d�35߄�J ,����fb��� bD q����u�s��}���}νw������s������{�v = � p p,P �
� 4 ��W��� O���l�Fp;�5�5m� ���#�{��ߕY գ�� �( �sY��������� �����8 �Ȉ^ � ΫC� ������ 8(�uK ֐�� �ӭ �GYc�B�h� s�{�E��� } PȠ�� /j.�Ϡ���yE� 0 ؽH#��/e;�EE��tX
� ��; #+���}T� ��
�؃ ��IQ=���� 8 � �,- � #�mo3 �� ��s�g�׀Y����� ������ N�}� dz[����0�o�� ��} �n�k� ȦX�E ����q ���
�T�?�g������ Y�-�.u�7WL@�� 8 ����:t �� qW�[ 4#���OU+jc' "�
� q \ �����s�2� ��J9 t� ��@ �m |�ZQÑ :,�2dι ���2\c���oX�� �(���,m�R��zE | x s ځֈ�44 ���)x��7��}V�C��, �Z\ � �2�VG:��pಘ�]�=��,ZIEND�B'�


How can I convert the data from the upload of image into base64?

Posted: Sat Mar 22, 2014 5:43 am
by Illya Stepanov

Hi Adam -

You can try to use this source: http://www.base64encode.org/


How can I convert the data from the upload of image into base64?

Posted: Sat Mar 22, 2014 6:14 am
by adam griffin

I do not understand the purpose of that link. I'm trying to have in my code the conversion of this type of data into base64. Then save that base64 data into the backend service.


How can I convert the data from the upload of image into base64?

Posted: Sat Mar 22, 2014 2:56 pm
by Igor

How can I convert the data from the upload of image into base64?

Posted: Sat Mar 22, 2014 5:49 pm
by adam griffin

These links are not helping at all..
Let me try being more specific. I have created a upload page like the one in this link http://docs.appery.io/tutorials/uploa... but i did not add file create service. I am just trying to save the Image data from the file content which is in the text area component into the backend service, but before I send the image data to the backend service I would like for the data to be shown as a Image in the Image component. How can I do this???


How can I convert the data from the upload of image into base64?

Posted: Mon Mar 24, 2014 1:42 am
by adam griffin

Can someone help me??


How can I convert the data from the upload of image into base64?

Posted: Mon Mar 24, 2014 3:04 am
by Igor

You don't need to convert it manually when select the file.

But if you realy want to convert some asset to base64 please take a look here: http://stackoverflow.com/questions/24...

For your goals please use "readAsDataURL" reader function instead of "readAsText".

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. 
     Appery("image_result").attr("src", base64String); 
 }; 
 //You are using this function. Comment it. 
 //reader.readAsText(file); 

 //Use this one. 
 reader.readAsDataURL(file); 

/pre


How can I convert the data from the upload of image into base64?

Posted: Mon Mar 24, 2014 3:21 am
by adam griffin

Thank you, so much for helping me instead of sending a link with no direction.

THANK YOU!


How can I convert the data from the upload of image into base64?

Posted: Mon Mar 24, 2014 5:54 am
by adam griffin

I was following this example http://docs.appery.io/tutorials/uploa... . When I click the "Select File to Upload" button in the browser the choose files opens to upload a file, but on device it doesn't work. Do you know how to fix this so it works on device? It works on browser but not on device.


How can I convert the data from the upload of image into base64?

Posted: Mon Mar 24, 2014 5:54 am
by adam griffin

I was following this example http://docs.appery.io/tutorials/uploa... . When I click the "Select File to Upload" button in the browser the choose files opens to upload a file, but on device it doesn't work. Do you know how to fix this so it works on device? It works on browser but not on device.