Skip to content

Instantly share code, notes, and snippets.

@dgreenway
Created September 27, 2013 18:41
Show Gist options
  • Save dgreenway/6733222 to your computer and use it in GitHub Desktop.
Save dgreenway/6733222 to your computer and use it in GitHub Desktop.
Create a data URI from a file
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment