zero1 Posted March 6, 2008 Share Posted March 6, 2008 Hi all, I can't get the specific answer on my search query in this forum so I've decided to post one. So pardon me for being n00bish, here goes my question. Let's say I have this code... <? echo "Downloading file......"; file_get_contents("BigFile.Dat"); echo "done!"; ?> In my test, echo only shows after the script have finished downloading the file. How can I make the webpage show before download ... Downloading file...... ...and display next after download... Downloading file......done! I'll be needing this to inform the user that the script is still processing just as to not let them think that the browser hanged. Link to comment https://forums.phpfreaks.com/topic/94798-getting-output-while-php-script-processing/ Share on other sites More sharing options...
Naez Posted March 6, 2008 Share Posted March 6, 2008 Sounds like something that needs to be accomplished by AJAX. PHP itself will just take forever to load while it downloads file then display "Downloading file...done" Link to comment https://forums.phpfreaks.com/topic/94798-getting-output-while-php-script-processing/#findComment-485479 Share on other sites More sharing options...
zero1 Posted March 6, 2008 Author Share Posted March 6, 2008 Hmmm.. AJAX. I can accomplish the same task with iframe but I need a pure PHP code. How bout this , what if I open a socket to the client that accesses the PHP page then send a HTTP reply. Would it be possible? or how about using "headers"? Sort of like... <? $fp = fsockopen ($host, 80); fwrite($fp,"HTTP/1.1 200 OK\r\nContent-Type: text/hml\r\n\r\nDownloading file......"); file_get_contents("BigFile.Dat"); fwrite($fp,"HTTP/1.1 200 OK\r\nContent-Type: text/hml\r\n\r\ndone!"); ?> Haven't anyone accomplished this? Is it possible to get the handle of the current socket transaction, which is the first instance the user accesses your script? Thanks for the reply. Link to comment https://forums.phpfreaks.com/topic/94798-getting-output-while-php-script-processing/#findComment-485519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.