How to display Base64 images in HTML?

后端 未结 11 2297
一整个雨季
一整个雨季 2020-11-21 06:10

I\'m having trouble displaying a Base64 image inline.

Can someone point me in the right direction?



  
         


        
11条回答
  •  盖世英雄少女心
    2020-11-21 06:49

    you can put your data directly in a url statment like

    src = 'url(imageData)' ;
    

    and to get the image data u can use the php function

    $imageContent = file_get_contents("imageDir/".$imgName);
    
    $imageData = base64_encode($imageContent);
    

    so you can copy paste the value of imageData and paste it directly to your url and assign it to the src attribute of your image

提交回复
热议问题