Last active
March 31, 2018 10:58
-
-
Save bitkorn/0cbb7c45f8b7638094377a4dd43567bc to your computer and use it in GitHub Desktop.
image encode Base64 PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = 'anhaenger.jpg'; | |
//$filename = 'anhaenger.png'; | |
$path = 'img/' . $filename; | |
$type = pathinfo($path, PATHINFO_EXTENSION); | |
$data = file_get_contents($path); | |
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); | |
file_put_contents('base64/' . substr($filename, 0, (strrpos($filename, '.'))), $base64); | |
echo $base64; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment