Created
July 9, 2014 11:22
-
-
Save xmalinov/853b5ba7ad726d160b61 to your computer and use it in GitHub Desktop.
Convert Image To Data URI With 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
$str = 'This is an encoded string'; | |
echo base64_encode($str); | |
$image = 'myimage.png'; | |
$type = pathinfo($image, PATHINFO_EXTENSION); | |
$data = file_get_contents($image); | |
$dataUri = 'data:image/' . $type . ';base64,' . base64_encode($data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment