{"record":{"id":"7fa1653fbdfaf01c","repo":"octobercms/october","slug":"editor-lang-filesystem-file-not-valid","errorCode":null,"errorMessage":"editor::lang.filesystem.file_not_valid","messagePattern":"editor::lang\\.filesystem\\.file_not_valid","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/editor/traits/FileSystemFunctions.php","lineNumber":262,"sourceCode":"            }\n        }\n    }\n\n    /**\n     * editorUploadFiles\n     */\n    protected function editorUploadFiles($basePath, $allowedExtensions)\n    {\n        $uploadedFile = Input::file('file');\n        if (!is_object($uploadedFile)) {\n            return;\n        }\n\n        $fileName = $uploadedFile->getClientOriginalName();\n\n        // Check valid upload\n        if (!$uploadedFile->isValid()) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.file_not_valid'));\n        }\n\n        // Check file size\n        $maxSize = UploadedFile::getMaxFilesize();\n        if ($uploadedFile->getSize() > $maxSize) {\n            throw new ApplicationException(Lang::get(\n                'editor::lang.filesystem.too_large',\n                ['max_size' => File::sizeToString($maxSize)]\n            ));\n        }\n\n        // Check for valid file extensions\n        if (!$this->validateFileSystemFileExtension($fileName, $allowedExtensions)) {\n            throw new ApplicationException(Lang::get(\n                'editor::lang.filesystem.type_not_allowed',\n                ['allowed_types' => implode(', ', $allowedExtensions)]\n            ));\n        }","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/editor/traits/FileSystemFunctions.php#L244-L280","documentation":"editorUploadFiles rejects any upload where Symfony's UploadedFile::isValid() is false, i.e. $_FILES['file']['error'] is not UPLOAD_ERR_OK. This runs before the size and extension checks and means PHP itself recorded an upload error: partial upload (UPLOAD_ERR_PARTIAL), client MAX_FILE_SIZE field exceeded (UPLOAD_ERR_FORM_SIZE), extension aborted (UPLOAD_ERR_EXTENSION), missing/unwritable tmp dir (UPLOAD_ERR_NO_TMP_DIR), or write-to-disk failure.","triggerScenarios":"Uploading through the editor file manager when the POST body is interrupted (flaky network or Nginx client_max_body_size smaller than PHP's limits truncating the multipart body); php.ini upload_tmp_dir pointing to a non-writable directory; a MAX_FILE_SIZE hidden field in a customized form smaller than the chosen file; a PHP extension (e.g. mod_security-like) aborting the upload.","commonSituations":"Fresh server or container where upload_tmp_dir is missing; php.ini limits tuned after migration without restarting php-fpm; reverse-proxy body limits inconsistent with PHP; customized editor upload forms that inject their own MAX_FILE_SIZE.","solutions":["Identify the exact code: log Input::file('file')->getError() (or $_FILES['file']['error']) and map it against the UPLOAD_ERR_* constants — the fix differs per code","If UPLOAD_ERR_NO_TMP_DIR/CANT_WRITE: fix upload_tmp_dir in php.ini (or unset it to use the system default) and confirm the directory is writable by the PHP user","If UPLOAD_ERR_INI_SIZE/UPLOAD_ERR_FORM_SIZE: raise upload_max_filesize and post_max_size, and raise or remove the client-side MAX_FILE_SIZE hidden field","Align the reverse proxy (Nginx client_max_body_size, Apache LimitRequestBody) with the PHP limits so bodies are not truncated","If UPLOAD_ERR_PARTIAL/UPLOAD_ERR_EXTENSION: retry on a stable connection and check for security middleware aborting uploads"],"exampleFix":"; php.ini — before\nupload_max_filesize = 2M\npost_max_size = 8M\n\n; after\nupload_max_filesize = 32M\npost_max_size = 34M\n\n# nginx — keep the proxy consistent with PHP\nclient_max_body_size 34m;","handlingStrategy":"validation","validationCode":"$file = Input::file('file');\nif (!$file instanceof \\Symfony\\Component\\HttpFoundation\\File\\UploadedFile || !$file->isValid()) {\n    $code = $file?->getError() ?? 'no file uploaded';\n    return Response::json(['error' => 'Upload rejected (code '.$code.')'], 422);\n}","typeGuard":"function uploadedFileOk(mixed $f): bool {\n    return $f instanceof \\Symfony\\Component\\HttpFoundation\\File\\UploadedFile && $f->isValid();\n}","tryCatchPattern":"try {\n    $this->editorUploadFiles($basePath, $allowed);\n} catch (ApplicationException $e) {\n    // Distinguish upload-error codes for actionable UI feedback\n    Flash::error($e->getMessage());\n}","preventionTips":["Keep upload_tmp_dir existing and writable; verify after every server/container rebuild","Align upload_max_filesize, post_max_size, and the reverse-proxy body limit as one unit","Do not inject client MAX_FILE_SIZE fields smaller than the server limit"],"tags":["upload","php-ini","editor","file-manager","multipart"],"backgroundTag":"invalid-file-upload","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}