Posted By

dexter on 01/14/11


Tagged

img base64


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


image bas64


 / Published in: PHP
 

  1. <?php
  2.  
  3. $img_src = "kep.jpg";
  4. $imgbinary = fread(fopen($img_src, "r"), filesize($img_src));
  5. $img_str = base64_encode($imgbinary);
  6. echo '<img src="data:image/jpg;base64,'.$img_str.'" />';
  7.  
  8. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: prashantvictory on January 15, 2011

This is cool, it encrypts your image name.

But when to use this, I mean where & why people prefer base64 encoding for images?

I just want to know the reasons so that I can decide that I need to use it for my website or not.

Posted By: dexter on February 6, 2011

The encoded image displayed, but it will not be downloaded, no security reasons

Posted By: dexter on February 6, 2011

other way it encrypts your img src, not name

You need to login to post a comment.