Javascript Hex String to Image

后端 未结 2 1454
轮回少年
轮回少年 2020-12-16 08:24

I\'ll cut right to the chase. Right now I am developing a web based application. It has a PHP REST based architecture that serves up XML documents. On many of these document

相关标签:
2条回答
  • 2020-12-16 08:54

    Encode the images using base64 and write them out in a CDATA string into your XML with this format:

    data:[<MIME-type>][;charset="<encoding>"][;base64],0123456789abcdefg...
    

    When constructing your document, use this string as your src

    <img src="data:image/png;base64,0123456789abcdefg..." />
    
    0 讨论(0)
  • 2020-12-16 08:57

    Is it possible to use a php file just for rendering the image? That php file could write some base64 encoded values via

    echo base64_decode($_GET['data']); 
    

    while you embed images like

    <img src="http://host/yourPhpFileForDecode.php?data=base64encoded.../>
    
    0 讨论(0)
提交回复
热议问题