Jump to content

Delay page load in PHP


kid_drew

Recommended Posts

Hey guys,

I have a Java applet that, on destruction, writes a postscript file to my server, and my server then converts that ps file to png to view in the next page that loads.  The problem is that the write from the java applet to the server takes longer than it takes for the page to load, and the conversion happens on the old file instead of the new one.  So the page has to get reloaded to see the new version of the png.  Is there a way to somehow delay the loading of the next PHP page?

 

-Drew

Link to comment
https://forums.phpfreaks.com/topic/49746-delay-page-load-in-php/
Share on other sites

At the very top of your php script you should be able to put something like

<?php
$i = 0;
while(!file_exists(path/to/the/image.png) && $i < 20) {
usleep(500); //pause script execution for .5 seconds.
}

if($i == 19) { //the $i was to make sure the script doesn't go into an infinite loop ;p
echo "Your image may have not been created....  Please try refreshing the page.";
}
else {
//display the image and whatnot
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.