octobercms/october · error · ApplicationException

editor::lang.filesystem.file_not_valid

Error message

editor::lang.filesystem.file_not_valid

What it means

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.

Source

Thrown at modules/editor/traits/FileSystemFunctions.php:262

            }
        }
    }

    /**
     * editorUploadFiles
     */
    protected function editorUploadFiles($basePath, $allowedExtensions)
    {
        $uploadedFile = Input::file('file');
        if (!is_object($uploadedFile)) {
            return;
        }

        $fileName = $uploadedFile->getClientOriginalName();

        // Check valid upload
        if (!$uploadedFile->isValid()) {
            throw new ApplicationException(Lang::get('editor::lang.filesystem.file_not_valid'));
        }

        // Check file size
        $maxSize = UploadedFile::getMaxFilesize();
        if ($uploadedFile->getSize() > $maxSize) {
            throw new ApplicationException(Lang::get(
                'editor::lang.filesystem.too_large',
                ['max_size' => File::sizeToString($maxSize)]
            ));
        }

        // Check for valid file extensions
        if (!$this->validateFileSystemFileExtension($fileName, $allowedExtensions)) {
            throw new ApplicationException(Lang::get(
                'editor::lang.filesystem.type_not_allowed',
                ['allowed_types' => implode(', ', $allowedExtensions)]
            ));
        }

View on GitHub (pinned to b608633a7e)

Solutions

  1. 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
  2. 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
  3. 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
  4. Align the reverse proxy (Nginx client_max_body_size, Apache LimitRequestBody) with the PHP limits so bodies are not truncated
  5. If UPLOAD_ERR_PARTIAL/UPLOAD_ERR_EXTENSION: retry on a stable connection and check for security middleware aborting uploads

Example fix

; php.ini — before
upload_max_filesize = 2M
post_max_size = 8M

; after
upload_max_filesize = 32M
post_max_size = 34M

# nginx — keep the proxy consistent with PHP
client_max_body_size 34m;
Defensive patterns

Strategy: validation

Validate before calling

$file = Input::file('file');
if (!$file instanceof \Symfony\Component\HttpFoundation\File\UploadedFile || !$file->isValid()) {
    $code = $file?->getError() ?? 'no file uploaded';
    return Response::json(['error' => 'Upload rejected (code '.$code.')'], 422);
}

Type guard

function uploadedFileOk(mixed $f): bool {
    return $f instanceof \Symfony\Component\HttpFoundation\File\UploadedFile && $f->isValid();
}

Try / catch

try {
    $this->editorUploadFiles($basePath, $allowed);
} catch (ApplicationException $e) {
    // Distinguish upload-error codes for actionable UI feedback
    Flash::error($e->getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/7fa1653fbdfaf01c. Report an issue: GitHub.