This code will help you learn how to convert an image into a base64 string.
Image to Base64 String
/**
* @author vir0e5 a.k.a banditc0de
* @copyright 2010 by vir0e5
* @authorurl http://facebook.com/vir0e5.vbs
* @Blog http://banditc0de.blogspot.com
This code will help you to learn how we can convert an image into a base64 string!!
*/
echo"
Image
";
//$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 = '';
echo $encode;
}
?>
Copy code
Convert to, PHP
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn