I'm trying to let user download file (~2GB) available with public url on to my server space available for user. Here are my two questions.
Q1: how to keep running a task initiated by user even after user closing the browser?
Q2: how to catch already running task status and show to user?
Below is my use case description.
Requirement:
- User Login -> request a file to download from public url -> close browser
- user login -> view current running downloads status + if downloads complete, let user download file to his local computer.
What's done: using curl able to download to web server and if user not closed browser, everything is good. unable to continue process if user closes browser.
Restrictions:
- don't want to use back-end database.
- should be persistent
Server: php + apache .2 + libcurl + ubuntu 12.10
let me know if it makes more sense to use any other technology / environment.
To keep the script running, even when the browser is closed, give this a try:
ignore_user_abort(true);
This should let the script continue even if the user disconnects (closes browser).
Source: http://php.net/manual/en/function.ignore-user-abort.php