How to open and display directory images with php?

0

Hello everyone trying to protect my images I created a .htaccess file in my image directory, this is my code:

order deny,allow
deny from all

But I have noticed that I can still access my images with the fpdf library that has a function called image: $this->Image('uploads/logoempresa/1.png',10,6,30);

And since I can not directly access the html tag to my images I would like to print them using some php function. Since I do not want them to be able to access my third images and that can only be opened from php.

    
asked by Daniel Treviño 23.10.2017 в 00:17
source

1 answer

2

Maybe this can help you:

<?php
$img = "comment.png";
$dat = base64_encode(file_get_contents($img));
$src = 'data:'.mime_content_type($img).';base64,'.$dat;

echo "<img src=\"$src\">";
?>
    
answered by 23.10.2017 / 00:37
source