I've got a page where there's some decompressing going on. The user first looks at a list of files, then they hit a button at which point a new page is called and the code kicks in.
I want the fact that there's a new page to be evident. Right now, the processing starts, but from the user's standpoint, the page hasn't changed.
How can I get things happening aesthetically so the fact that something is happening is evident?
I've got the source code of the page below. It takes about 10 seconds for the processing to occur. It's not until that 10 seconds has expired that the top of the page where I have my verbiage is displayed.
How can I get "Your files are being decompressed" to be displayed at the top of the page while the processing is taking place?
$dir_name = 'JSON/';
if ($dh = opendir("$dir_name"))
while (($file = readdir($dh)) !== false)
//omitting the system default of listing "." and ".."
//make sure we're only reading files with a .gz extension
$info = new SplFileInfo($file);
//at this point, look to see if the name of that file is in the database and needs to be processed
$daniel = "select file_name from raw_files where file_name='$file'";
//insert current date and time into your raw_files table
$now= date('Y-m-d H:i:s');
$nelson="insert into raw_files (file_name, start_time) value('$file', '$now')";
$novie_id = $cxn->insert_id;
//here's your decompression code
$file_name = $file;
// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '', $file_name);
// Open our files (in binary mode)
$the_file = gzopen($file_name, 'rb');
$out_file = fopen('JSON/'.$out_file_name, 'wb');
// Keep repeating until the end of the input file
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
fwrite($out_file, gzread($the_file, $buffer_size));
// Files are done, close files
//here's where you update the raw_files database with a time it was completed
$right_now= date('Y-m-d H:i:s');
$brice="update raw_files set end_time = '$right_now' where id=$novie_id";
or die("Brice didn't happen.");
//echo "$file <br>\n";
echo "files are decompressed...";