kid_drew Posted May 3, 2007 Share Posted May 3, 2007 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 Quote Link to comment Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 sleep() or usleep() Quote Link to comment Share on other sites More sharing options...
kid_drew Posted May 3, 2007 Author Share Posted May 3, 2007 Yeah, that isn't working. It seems like it grabs the image that was there when the script started loading.....or something. I'm totally confused by this. Quote Link to comment Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 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 } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.