{"record":{"id":"8c97d761eccb3431","repo":"octobercms/october","slug":"file-missing-from-request-8c97d7","errorCode":null,"errorMessage":"File missing from request","messagePattern":"File missing from request","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/media/widgets/MediaManager.php","lineNumber":1568,"sourceCode":"        $quickMode = false;\n\n        if (\n            (!($uniqueId = Request::header('X-OCTOBER-FILEUPLOAD')) || $uniqueId !== $this->getId()) &&\n            (!$quickMode = post('X_OCTOBER_MEDIA_MANAGER_QUICK_UPLOAD'))\n        ) {\n            return;\n        }\n\n        // Set locale early since this runs in the widget constructor,\n        // before the controller applies the user's locale preference\n        \\Backend\\Models\\Preference::setAppLocale();\n\n        if (!$this->checkHasPermission('mediaCreate')) {\n            throw new ForbiddenException;\n        }\n\n        if (!Input::hasFile('file_data')) {\n            throw new ApplicationException('File missing from request');\n        }\n\n        try {\n            $uploadedFile = files('file_data');\n\n            /**\n             * @event media.file.beforeUpload\n             * Called before a file is uploaded\n             *\n             * Example usage:\n             *\n             *     Event::listen('media.file.beforeUpload', function ((\\Symfony\\Component\\HttpFoundation\\File\\UploadedFile) $uploadedFile) {\n             *         \\Log::info($path . \" was uploaded.\");\n             *     });\n             *\n             * Or\n             *\n             *     $mediaWidget->bindEvent('file.beforeUpload', function ((\\Symfony\\Component\\HttpFoundation\\File\\UploadedFile) $uploadedFile) {","sourceCodeStart":1550,"sourceCodeEnd":1586,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/media/widgets/MediaManager.php#L1550-L1586","documentation":"ApplicationException thrown at MediaManager.php:1568 when the upload AJAX request reaches the handler without any file under the 'file_data' field (Input::hasFile('file_data') is false). The widget already checked the mediaCreate permission and set the locale, so the request itself authenticated fine — the multipart payload simply contained no file.","triggerScenarios":"Uploading via onUpload with a wrong field name, a JSON body instead of multipart/form-data, or — the classic case — a file that exceeds PHP's post_max_size, which causes PHP to drop the entire $_FILES/$_POST array so the request looks empty. The handler is also used for Froala image uploads, which must use the file_data param name.","commonSituations":"Uploading large videos/images where upload_max_filesize or post_max_size (and nginx client_max_body_size) are too small; custom upload forms renaming the input; JS sending FormData without the file appended; reverse proxies stripping the body.","solutions":["Raise PHP limits: upload_max_filesize and post_max_size (post_max_size must exceed the file size), plus client_max_body_size in nginx / LimitRequestBody in Apache, then restart PHP-FPM.","Ensure the client sends multipart/form-data with the field named exactly 'file_data' (this is Froala's imageParamName default wiring in the media manager).","For custom code, append the File/Blob to FormData under the 'file_data' key before the request."],"exampleFix":"// before (custom uploader)\nconst fd = new FormData();\nfd.append('upload', file);\n\n// after\nconst fd = new FormData();\nfd.append('file_data', file);","handlingStrategy":"validation","validationCode":"// Client-side, before upload\nif (!(file instanceof File) || file.size === 0) {\n    alert('No file selected.');\n    return;\n}\nconst fd = new FormData();\nfd.append('file_data', file);\nfd.append('path', currentPath);","typeGuard":"function hasUploadFile(form, field = 'file_data') {\n    const input = form.elements[field];\n    return !!input && !!input.files && input.files.length > 0 && input.files[0].size > 0;\n}","tryCatchPattern":"try {\n    await $.request('onUpload', { data: fd });\n} catch (e) {\n    // Empty $_FILES usually means the body exceeded post_max_size\n    if (/File missing from request/.test(e.responseText || '')) {\n        alert('File too large for the server limit (post_max_size).');\n    }\n}","preventionTips":["Set upload_max_filesize and post_max_size above your largest expected asset, and nginx client_max_body_size above post_max_size.","Always use multipart/form-data with the field name file_data.","Client-side, reject files above the documented server limit before uploading."],"tags":["media-manager","upload","file-data","php-ini","post-max-size","multipart"],"backgroundTag":"upload-request-empty-files","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}