troubleshooting Question

Unlink priority? Seems to delete before running other code

Avatar of hqnetwork
hqnetwork asked on
9 Comments1 Solution428 ViewsLast Modified:
I have a small script that is supposed to display an image, then delete it directly after it is displayed on screen. However, php's unlink(); command seems to be deleting the image before it is displayed.

the Unlink is definitely below where the image is displayed, as well as being encapsulated within an IF statement to ensure it's not executed before it should be.

Perhaps I need to use a different method to delete?

BTW, this is on a linux box as you can probably tell byt eh $img2delete path.
printf("<img src='".$dir.$file."'><br>");
	$_SESSION['curr_file'] = $file;
	$img2delete = '/var/www/html/Images/'.$_SESSION['curr_file'];
	$diff = (time() - filemtime("$img2delete"))/60*60;
	echo "<p>File age in seconds: $diff</p>\n";
	$isviewed = "true";
	if($isviewed == 'true') {
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros