This is a section from a webpage I've made:
<?php
echo "<img src='picture.php?spray=".$spray."' style='display:none'>";
?>
<?php
if (file_exists("wallwithtext.png"))
{
echo "<img src='wallwithtext.png'>";
}
else
{
echo "<img src='wall.png'>";
}
?>
picture.php outputs the results to the file "wallwithtext.png" as wanted, except the line echo "<img src='wallwithtext.png'>"; executes before picture.php finishes updating the file and hence the file displayed is always "outdated". I've tried sleep, usleep and a for next loop counting up to 10000 incrementing by .5 and to slow the loading down but they don't work...
Any suggestions, Thanks.