I am executing a Python file, that saves images to folders called ‘latestimage.png’ to a folder, in a PHP web page using this:
$proc = popen('python -u python.py', 'r');
echo '<pre>';
while (!feof($proc))
{
echo fread($proc, 4096);
}
echo '</pre>';
}
As you can see there is a while loop that stops anything else from happening until the script is finished executing. I have a DIV that shows the latest version of ‘latestimage.png’:
<?php
$filepath = $_SESSION['filepath'];
$new_file = $filepath ."\latestimage.png";
?>
<img src="<?php echo $new_file; ?>">
</div>
I want to know how to dynamically update the DIV so that every time the Python file creates a new image, the DIV is updated to show the new image. Thanks.
2
Answers
Since is part of HTML and HTML is only looked at on the client-side you going to need to use something like AJAX that will request the image from the server for you just given the URL of it. You will have to do this every so often so you know that you are getting the latest version of the photo
try this