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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -