Image into a base64 string [PHP] Rahman Surya Praja Selasa, 26 April 2011 No Comment


Ini adalah Contoh Encrypt file image dengan metode base64, menggunakan bahasa PHP







<title>Image to Base64 String</title>
  <fieldset>
 <legend>Image to Base64 String</legend>
  <center>
  <form name="select_all">
    <?php
    /**

  This code will help you to learn how we can convert an image into a base64 string!!
 */
                 echo"<h3><p>Image</p></h3>";
     //$file = File Image yang ingin di encode 
     //Filetype: JPEG,PNG,GIF
     $file = "encode.jpg";
     if($fp = fopen($file,"rb", 0))
     {
     $gambar = fread($fp,filesize($file));
     fclose($fp);

     
     $base64 = chunk_split(base64_encode($gambar));
     //Result
     $encode = '<img src="data:image/jpg/png/gif;base64,' . $base64 .'" >';
     echo $encode;
     } 
    ?>
    <br><textarea  name="text_area" rows="20" cols="70"><? echo $encode; ?></textarea>
    <p><input type="button" value="Select All Code" onClick="javascript:this.form.text_area.focus();this.form.text_area.select();"></p>
  </form>
  </center>
 </fieldset>

by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

by Rahman Surya Praja

Freelance Forever

Follow him @ Twitter | Facebook | Google Plus

No Comment

Terima Kasih Sudah berkunjung!! Di Mohon Untuk Meninggalkan Komen, untuk mempererat silaturahmi.... ^_^