Why Moodle Fails to Unzip Large Files: The 2x Size Trap
Moodle keeps the original zip on disk while extracting it, so the peak space required is twice the zip size — and it is the course upload limit, not PHP's upload setting, that usually triggers the failure.
Uploading a large zip file to Moodle succeeds, but extracting it inside a File resource fails with a generic error. The reason is that Moodle retains the original archive while unpacking, so extraction requires temporary space equal to the zip plus its uncompressed contents — and this combined size is checked against the course-level upload limit.
The three-layer limit stack
Moodle enforces file size limits at three levels, and all three must be satisfied:
- PHP (
upload_max_filesize,post_max_sizeinphp.ini) — governs the initial HTTP upload. - Site (
$CFG->maxbytes, set in Site administration > Security > Site security settings) — the global ceiling. - Course (per-course maximum upload size, inherited from the site default unless overridden) — applied when files are used inside the course context.
Most administrators raise the PHP and site limits when large uploads are needed. The course-level limit is easy to miss.
Why the math catches you out
Consider a 600 MB zip file containing a large SCORM package or video collection. The actual uncompressed size is also approximately 600 MB. During extraction:
- The zip file remains on disk: 600 MB
- The extracted files are written alongside it: 600 MB
- Peak combined usage: ~1.2 GB
If the course upload limit is 1 GB, extraction fails. The upload succeeded because 600 MB is under 1 GB. The extraction fails because 1.2 GB is not.
The error message Moodle shows — something like “Cannot unzip file” — does not explain this. It looks identical to a corrupt zip or a permissions error.
Finding which limit is triggering
Check the course-level limit first. In the course settings:
Course settings > Files and uploads > Maximum upload size
If this is set to “Site upload limit” rather than a specific value, check the site limit:
Site administration > Security > Site security settings > Maximum uploaded file size
Cross-reference against php.ini:
php -r "echo ini_get('upload_max_filesize'), ' / ', ini_get('post_max_size'), PHP_EOL;"
The effective limit is the minimum of all three. The course limit is the one most likely to be set too low.
The fix
Temporarily increase the course upload limit to at least twice the zip file size before attempting extraction:
Course settings > Files and uploads > Maximum upload size > Set to 2 GB (or higher)
Save, extract the zip in the File resource, then reduce the limit back to a sensible value.
If the site limit is the bottleneck, raise it temporarily in:
Site administration > Security > Site security settings > Maximum uploaded file size
Do not leave an inflated limit in place permanently — it affects all courses on the site.
Avoiding the problem
For very large archives, consider unpacking on the server directly
rather than through the Moodle interface. Upload the zip via SFTP,
extract it into the correct moodledata path, and use
php admin/cli/files_refresh.php or the file repair tool to
register the files. This bypasses all three upload limits entirely.
Alternatively, for SCORM packages specifically, some authoring tools can produce smaller packages by splitting large assets (video) out of the SCORM zip and referencing them as external resources.
Solin provides Moodle administration, configuration, and end-user support.
Contact us