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
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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.