php - Delete an image after it has been seen by a visitor -
i want show visitors images in folder , after have seen it, want files deleted!
this tried, won't work. think it's because php generating html file tells browser must first image different place html file removed.
<?php foreach (glob("files/*.*") $prevpic) { echo '<img src="' . $prevpic . '" />'; } foreach (glob("files/*.*") $file) { unlink($file); } move_uploaded_file($_files["file"]["tmp_name"], "files/" . $_files["file"]["name"]); ?>
you can ...
<?php foreach (glob("files/*.*") $file) { echo '<img src="data:image/' . pathinfo($file, pathinfo_extension) . ';base64,' . base64_encode(file_get_contents($file)) . '" />'; unlink($file); } ?>
... writing image data html, , discarding image.
Comments
Post a Comment