phacility/phabricator · error · Exception

File is not an uploaded file.

Error message

File is not an uploaded file.

What it means

is_uploaded_file() guard: enable_post_data_reading is on, so PHP parsed the body itself, but the temp path in the spec is not a registered uploaded file — indicating a spoofed or internally misrouted upload spec.

Solutions

  1. Ensure uploads flow through a genuine multipart POST handled by PHP
  2. If a custom client builds the spec array manually, disable enable_post_data_reading so the check is skipped (as the code comment notes)
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:207 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/2f98813bd4cb410b. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/files/storage/PhabricatorFile.php:207

      throw new Exception(pht('No file was uploaded!'));
    }

    $err = idx($spec, 'error');
    if ($err) {
      throw new PhabricatorFileUploadException($err);
    }

    $tmp_name = idx($spec, 'tmp_name');

    // NOTE: If we parsed the request body ourselves, the files we wrote will
    // not be registered in the `is_uploaded_file()` list. It's fine to skip
    // this check: it just protects against sloppy code from the long ago era
    // of "register_globals".

    if (ini_get('enable_post_data_reading')) {
      $is_valid = @is_uploaded_file($tmp_name);
      if (!$is_valid) {
        throw new Exception(pht('File is not an uploaded file.'));
      }
    }

    $file_data = Filesystem::readFile($tmp_name);
    $file_size = idx($spec, 'size');

    if (strlen($file_data) != $file_size) {
      throw new Exception(pht('File size disagrees with uploaded size.'));
    }

    return $file_data;
  }

  public static function newFromPHPUpload($spec, array $params = array()) {
    $file_data = self::readUploadedFileData($spec);

    $file_name = nonempty(
      idx($params, 'name'),

View on GitHub (pinned to 5720a38cfe)