{"record":{"id":"a2b3f2dc00f79f0e","repo":"BookStackApp/BookStack","slug":"file-filename-exceeds-app-upload-limit","errorCode":null,"errorMessage":"File $fileName exceeds app upload limit.","messagePattern":"File \\$fileName exceeds app upload limit\\.","errorType":"validation","errorClass":"ZipImportException","httpStatus":null,"severity":"error","filePath":"app/Exports/ZipExports/ZipImportRunner.php","lineNumber":260,"sourceCode":"        return $image;\n    }\n\n    protected function exportTagsToInputArray(array $exportTags): array\n    {\n        $tags = [];\n\n        /** @var ZipExportTag $tag */\n        foreach ($exportTags as $tag) {\n            $tags[] = ['name' => $tag->name, 'value' => $tag->value ?? ''];\n        }\n\n        return $tags;\n    }\n\n    protected function zipFileToUploadedFile(string $fileName, ZipExportReader $reader, bool $forceExtensionFromMime = false): UploadedFile\n    {\n        if (!$reader->fileWithinSizeLimit($fileName)) {\n            throw new ZipImportException([\n                \"File $fileName exceeds app upload limit.\"\n            ]);\n        }\n\n        $tempPath = tempnam(sys_get_temp_dir(), 'bszipextract');\n        $fileStream = $reader->streamFile($fileName);\n        $tempStream = fopen($tempPath, 'wb');\n        stream_copy_to_stream($fileStream, $tempStream);\n        fclose($tempStream);\n\n        $this->tempFilesToCleanup[] = $tempPath;\n\n        $intendedUploadName = $fileName;\n        if ($forceExtensionFromMime) {\n            $mime = $reader->sniffFileMime($fileName);\n            $extension = explode('/', $mime)[1];\n            if (!str_ends_with(strtolower($intendedUploadName), '.' . $extension)) {\n                $intendedUploadName .= '.' . $extension;","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Exports/ZipExports/ZipImportRunner.php#L242-L278","documentation":"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.","triggerScenarios":"ZIP export contains an image or attachment whose uncompressed size exceeds config('app.upload_limit') MB during importBook/importAttachment/importImage.","commonSituations":"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.","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."],"exampleFix":"// before (.env on target)\nAPP_UPLOAD_LIMIT=5\n// after\nAPP_UPLOAD_LIMIT=100","handlingStrategy":"validation","validationCode":"$zip = new ZipArchive();\n$zip->open($path);\n$limit = max((int) config('app.upload_limit'), 1) * 1000000;\nfor ($i = 0; $i < $zip->numFiles; $i++) {\n    $stat = $zip->statIndex($i);\n    if ($stat['size'] > $limit) {\n        throw new \\RuntimeException(\"{$stat['name']} exceeds upload limit\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $runner->run($import, $parent);\n} catch (\\BookStack\\Exceptions\\ZipImportException $e) {\n    // message names the oversized file; raise limit or shrink it\n}","preventionTips":["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."],"tags":["zip-import","bookstack","upload-limit","attachments"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}