Hi all,
On my project some PDF documents and images are storage outside the web public folder, so I just can't reach then just with a simple link and I need to display then on a page.
$fileDir = '../data/contas';
For images I use the code below (this solution I found on web):
$fileDir = '../data/contas/';
function data_uri($conta, $mime)
{
$contents = file_get_contents($conta);
$base64 = base64_encode($contents);
return "data:$mime;base64,$base64";
)
<img src="<?php echo data_uri($conta, 'image/png');?>" width="720">
When I see the HTML code I got <img src="data:image/png;base64,/9j/4AAQSkZJRgABA...(huge amount of string)...FXYq/wD/2Q==" width="720"> and the images are displayed correctly.
The problem occurs on PDF files, I use the same function, as follow below and the PDF document is not displaying, there is no error message just a gray background where the document were to be shown.
<EMBED SRC='<?php echo data_uri($conta, 'application/pdf');?>#view=FitH,top&toolbar=1&navpanes=0&scrollbar=1&zoom=scale' WIDTH="720" HEIGHT="900" ALIGN="TOP"></EMBED>
When I look at the HTML code it shows: <EMBED SRC='data:application/pdf;base64,JVBERi0xLjIK...(huge amount of string)...YK#view=FitH,top&toolbar=1&navpanes=0&scrollbar=1&zoom=scale' WIDTH="720" HEIGHT="900" ALIGN="TOP"></EMBED>
Any ideia how can I show the PDF files?
Or there is another way to access the files outside web public folder on server to display then?
Thankx
Danilo Jr.