I'm using a .htaccess file with the following code:
Order deny, allow
Deny from all
Allow from localhost
But when I display the images I'm just putting a link to the image in an tag, but the images are not showing up.
How can I display the image but disallow direct access to it? Is there a way for me to just copy the raw bytes of the file and display them?
Be sure to save embedded.png in same folder as this example source.
<?php
function data_uri($file, $mime)
{
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64);
}
?>
<html>
<h1>Embedded Image:-</h1>
<img src="<?php echo data_uri('embedded.png','image/png'); ?>" alt="Embedded image" />
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With