{"record":{"id":"a21e2b6afba7606a","repo":"phacility/phabricator","slug":"file-size-disagrees-with-uploaded-size","errorCode":null,"errorMessage":"File size disagrees with uploaded size.","messagePattern":"File size disagrees with uploaded size\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/storage/PhabricatorFile.php","lineNumber":215,"sourceCode":"    $tmp_name = idx($spec, 'tmp_name');\n\n    // NOTE: If we parsed the request body ourselves, the files we wrote will\n    // not be registered in the `is_uploaded_file()` list. It's fine to skip\n    // this check: it just protects against sloppy code from the long ago era\n    // of \"register_globals\".\n\n    if (ini_get('enable_post_data_reading')) {\n      $is_valid = @is_uploaded_file($tmp_name);\n      if (!$is_valid) {\n        throw new Exception(pht('File is not an uploaded file.'));\n      }\n    }\n\n    $file_data = Filesystem::readFile($tmp_name);\n    $file_size = idx($spec, 'size');\n\n    if (strlen($file_data) != $file_size) {\n      throw new Exception(pht('File size disagrees with uploaded size.'));\n    }\n\n    return $file_data;\n  }\n\n  public static function newFromPHPUpload($spec, array $params = array()) {\n    $file_data = self::readUploadedFileData($spec);\n\n    $file_name = nonempty(\n      idx($params, 'name'),\n      idx($spec,   'name'));\n    $params = array(\n      'name' => $file_name,\n    ) + $params;\n\n    return self::newFromFileData($file_data, $params);\n  }\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/storage/PhabricatorFile.php#L197-L233","documentation":"Error \"File size disagrees with uploaded size.\" thrown in phacility/phabricator.","triggerScenarios":"Thrown at src/applications/files/storage/PhabricatorFile.php:215 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}