I'm trying to show any file in the browser using PHP and headers, but it isn't working with a PNG image, it shows a strange black square like this:
Here is my code:
<?php
header('Content-Type: ' . mime_content_type($filepath));
readfile($filepath);
die();
?>
I already checked the $filepath
variable, its the full path (E:\wwwPublic\myapp\application\controllers\..\..\documents\34807\image.PNG
) I don't know what is going wrong in that code.
Do you have any idea(s) ?
I solved it, I found that Code Igniter has default headers, I needed to add ob_clean()
to remove all of them and add my own, Thank you for your help