DownloadZIP Extraction with Real-Time Progress (AJAX + PHP)
This is an example implementation of extracting a ZIP archive with live progress updates in the browser using AJAX, with progress stored in the PHP session.
It demonstrates the use of the extractWithProgress() method of the TZipHandler class from Ascoos OS.
Features
-
Real-time progress bar (percentage + current file name)
-
AJAX polling (no WebSocket required)
-
Progress stored in `$_SESSION`
-
jQuery interface
-
Handles empty archives & completion state
Requirements
-
PHP ? 8.3
-
Ascoos OS 1.0.0 or AWES 26 Pro
-
Sessions enabled
-
Write permissions on the extraction folder
-
jQuery
Installation
-
Download or clone the repository
-
Place the files on your web server
-
Adjust the paths inside `extractWithProgress.php` to match your environment:
$zipHandler->extractWithProgress(
'/path/to/your/archive.zip',
'/path/to/extraction/folder',
'ajaxProgressCallback'
);
Usage
-
Open `extractWithProgress.html` in your browser
-
Click Start Extract
-
Watch the progress bar and file log update in real time
Example output:
Extracted: folder/config.ini
Extracted: images/logo.png
...
Completed!
How it works (simplified)
Browser ---> Click "Start" ---> AJAX polling every 1s ---> extractWithProgress.php
|
v
reads $_SESSION['zip_progress']
|
v
returns JSON ? updates bar & log
The extraction runs inside one long PHP request, while progress is stored in the session and read by lightweight AJAX calls.
License
AGL (Ascoos General License).
© 2025-2026 Ascoos OS |