I made an upload script where user uploads a file after the upload user get redirected to next page where i dump that file to database and show a gif image of loading data.. and then put sleep(10) to create delay and replace that image with showing data. Problem
I am facing is that after upload the code takes sleep(10) as execution time and display the final output on the next page no matter how many delays are being passed in that file and all those delays adds up to the execution time and shows the user final output after the dump is being done. Kindly let me know why is this happening.
Note I used flush () it didnot work either and its enabled in my config file
<?php
flush();
ob_flush();
echo '<script language="javascript">document.getElementById("information").innerHTML="<img src='."images/L.gif".' />"</script>';
sleep(30);
echo '<script language="javascript">document.getElementById("information").innerHTML="<img src='."images/C.gif".' />"</script>';
?>
There are solutions to this (namely to
flushafter yourechostatement and before yoursleepstatement). But, this isn’t likely to do what you want cross-browser anyway. AJAX would be a much better solution for this sort of task (most likely).Depending on the browser and configuration, the browser may not start rendering anything until the connection to your server is closed. In this case, the user will see nothing on their screen until all of your delays have passed.