{"record":{"id":"4d519d1343c76c30","repo":"getgrav/grav","slug":"plugin-admin-file-could-not-be-deleted-plugin-adm","errorCode":null,"errorMessage":"PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN.BAD_FILENAME","messagePattern":"PLUGIN_ADMIN\\.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN\\.BAD_FILENAME","errorType":"exception","errorClass":"RuntimeException","httpStatus":400,"severity":"error","filePath":"system/src/Grav/Common/Media/Traits/MediaUploadTrait.php","lineNumber":350,"sourceCode":"     *\n     * @param string $filename\n     * @param array|null $settings\n     * @return void\n     * @throws RuntimeException\n     */\n    public function deleteFile(string $filename, ?array $settings = null): void\n    {\n        // Add the defaults to the settings.\n        $settings = $this->getUploadSettings($settings);\n        $filesystem = Filesystem::getInstance(false);\n\n        // First check for allowed filename. The name may carry a sub-path such as\n        // `original/photo.jpg`, which is kept and passed through to doRemove(), so\n        // the folder part has to be checked separately: Utils::checkFilename()\n        // alone only sees the last segment.\n        $basename = $filesystem->basename($filename);\n        if (!$this->checkFilepath($filename) || !Utils::checkFilename($basename)) {\n            throw new RuntimeException($this->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . \": {$this->translate('PLUGIN_ADMIN.BAD_FILENAME')}: \" . $filename, 400);\n        }\n\n        $path = $settings['destination'] ?? $this->getPath();\n        if (!$path) {\n            return;\n        }\n\n        /** @var UniformResourceLocator $locator */\n        $locator = $this->getGrav()['locator'];\n        $locator->clearCache();\n\n        $pathname = $filesystem->pathname($filename);\n\n        // Get base name of the file.\n        [$base, $ext,,] = $this->getFileParts($basename);\n        $name = \"{$pathname}{$base}.{$ext}\";\n\n        // Remove file and all all the associated metadata.","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php#L332-L368","documentation":"Error \"PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN.BAD_FILENAME\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:350 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":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}