Return to Snippet

Revision: 50193
at August 15, 2011 12:43 by alyssonweb


Initial Code
function base64_encode_image ($filename=string,$filetype=string) {
    if ($filename) {
        $imgbinary = fread(fopen($filename, "r"), filesize($filename));
        return 'data:image/' . $filetype . ';base64,' . base64_encode($imgbinary);
    }
}

Initial URL
http://php.net/manual/en/function.base64-encode.php

Initial Description
used as so

<style>
.logo {
    background: url("<?php>") no-repeat right 5px;
}
</style>

or

<img src="<?php>"/>

Initial Title
Base64 Image Encode

Initial Tags
image

Initial Language
PHP