Hi a server with a PHP script that deals with image downloads. After it finishes downloading all the images it zips them and then a user can download them.
To request this process a user clicks a button on a webpage which then tells my website to tell this other server to start this process. This is so the webserver which deals with requests doesn't deal with file downloads / zipping and it won't time out.
I was wondering how I can tell the progress of the zipping on the users webpage to notify the user when the zipping is complete?
I would make a queue file with the same name as the "the be created zip file" but with another extension.
On your server which creates the download file, let the script create another file with the same name but a status code as extension. (ex 123456789.PRO meaning in progress and 123456789.DON for it being ready) The script that makes the zip file can then update this file name, before start makes the file .PRO and finished .DON)
Now on your webserver do an ajax call which reads a PHP script, which in its return checks if the file exists.
file not there: process not started .PRO file exists: PROCESSING .DON file exists: Create download link
The ajax call could be checked every few seconds, up to you and how much server load you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With