<?php
ob_clean();
header('Content-Type: image/jpeg');
header('Content-Length: ' . filesize($file));
$file = '111111-11111.jpg';
$handle = fopen($file, "r");
echo file_get_contents($file);
?>
At one point my php webpage stopped displaying all and any images I had successfully uploaded to MySQL database. I wanted to get down to the roots of this problem and see if it could output a .jpg image stored on HDD and all I get is the same output as when I'm trying access this image from database:
The image [...] could not be displayed because it contains errors.
The image location is correct, there are no whitespaces before header, the output buffer has been cleaned. I have spent days on google searching for the answer, but without luck.
I am quite new to PHP so if you can help, please be as descriptive as you can be, so I could understand. Thank you in advance.
$handle = ...line as you are not using itini_set('display_errors', 0);to disable that.fopen()the file before usingfile_get_contents().