I have a script that displays an image from a file on the server. When done I want to delete the file.
Here is my code:
<?
echo "<br><img src=" . $filename . ">";
unlink($filename);
?>
If I run this I get an empty image displayed. If I comment out the unlink it works fine.
Tried to dump buffers with
ob_end_flush();
which gives me an error.
Not sure how to make sure the image displays and then delete the image from the temp dir.
I am using the time() function to create the tmp filename.
<?
$FileExtension = "TXT";
if (stristr($TheImageType, 'jpeg')) {
$FileExtension = "JPG";
}
$filename = "MyImages/" . time() . "." . $FileExtension;
?>
Works well but cannot delete the file.
Any ideas?
TIA
Frank