BookStackApp/BookStack · error · ZipImportException
File $fileName exceeds app upload limit.
Error message
File $fileName exceeds app upload limit.
What it means
ZipImportRunner::zipFileToUploadedFile() converts an embedded ZIP member into a simulated UploadedFile. Before extracting it calls ZipExportReader::fileWithinSizeLimit($fileName); if the member (image/attachment) exceeds the app.upload_limit it throws ZipImportException 'File $fileName exceeds app upload limit.' This aborts the import of that book/attachment/image.
Source
Thrown at app/Exports/ZipExports/ZipImportRunner.php:260
return $image;
}
protected function exportTagsToInputArray(array $exportTags): array
{
$tags = [];
/** @var ZipExportTag $tag */
foreach ($exportTags as $tag) {
$tags[] = ['name' => $tag->name, 'value' => $tag->value ?? ''];
}
return $tags;
}
protected function zipFileToUploadedFile(string $fileName, ZipExportReader $reader, bool $forceExtensionFromMime = false): UploadedFile
{
if (!$reader->fileWithinSizeLimit($fileName)) {
throw new ZipImportException([
"File $fileName exceeds app upload limit."
]);
}
$tempPath = tempnam(sys_get_temp_dir(), 'bszipextract');
$fileStream = $reader->streamFile($fileName);
$tempStream = fopen($tempPath, 'wb');
stream_copy_to_stream($fileStream, $tempStream);
fclose($tempStream);
$this->tempFilesToCleanup[] = $tempPath;
$intendedUploadName = $fileName;
if ($forceExtensionFromMime) {
$mime = $reader->sniffFileMime($fileName);
$extension = explode('/', $mime)[1];
if (!str_ends_with(strtolower($intendedUploadName), '.' . $extension)) {
$intendedUploadName .= '.' . $extension;View on GitHub (pinned to 18f8469a1c)
Solutions
- Increase APP_UPLOAD_LIMIT (config/app.php 'upload_limit') on the importing instance and run php artisan config:clear.
- Remove or shrink the offending file(s) from the source instance and re-export.
- Identify the file from the message ($fileName) and check its size with `unzip -l export.zip`.
- Import without the large attachment and add it manually afterward.
Example fix
// before (.env on target) APP_UPLOAD_LIMIT=5 // after APP_UPLOAD_LIMIT=100
Defensive patterns
Strategy: validation
Validate before calling
$zip = new ZipArchive();
$zip->open($path);
$limit = max((int) config('app.upload_limit'), 1) * 1000000;
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
if ($stat['size'] > $limit) {
throw new \RuntimeException("{$stat['name']} exceeds upload limit");
}
} Try / catch
try {
$runner->run($import, $parent);
} catch (\BookStack\Exceptions\ZipImportException $e) {
// message names the oversized file; raise limit or shrink it
} Prevention
- Pre-scan archive member sizes against the target instance's upload limit.
- Keep APP_UPLOAD_LIMIT consistent across exporting and importing instances.
- Compress or exclude oversized media before export.
- Run php artisan config:clear after limit changes.
When it happens
Trigger: ZIP export contains an image or attachment whose uncompressed size exceeds config('app.upload_limit') MB during importBook/importAttachment/importImage.
Common situations: Large media files exported from a source instance with a higher limit, imported into a target instance with a lower limit; default upload_limit on new installs; shared hosting constraints.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- errors.import_zip_data_too_large
- errors.import_zip_cant_decode_data
- Could not identify content in ZIP file data.
- errors.import_validation_failed
- Must not have a parent set for a Book import.
AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02).
Data as JSON: /api/errors/a2b3f2dc00f79f0e.
Report an issue: GitHub.