getgrav/grav · error · RuntimeException

PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN.BAD_FIL

Error message

PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN.BAD_FILENAME

What it means

Error "PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED: PLUGIN_ADMIN.BAD_FILENAME" thrown in getgrav/grav.

Source

Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:350

     *
     * @param string $filename
     * @param array|null $settings
     * @return void
     * @throws RuntimeException
     */
    public function deleteFile(string $filename, ?array $settings = null): void
    {
        // Add the defaults to the settings.
        $settings = $this->getUploadSettings($settings);
        $filesystem = Filesystem::getInstance(false);

        // First check for allowed filename. The name may carry a sub-path such as
        // `original/photo.jpg`, which is kept and passed through to doRemove(), so
        // the folder part has to be checked separately: Utils::checkFilename()
        // alone only sees the last segment.
        $basename = $filesystem->basename($filename);
        if (!$this->checkFilepath($filename) || !Utils::checkFilename($basename)) {
            throw new RuntimeException($this->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . ": {$this->translate('PLUGIN_ADMIN.BAD_FILENAME')}: " . $filename, 400);
        }

        $path = $settings['destination'] ?? $this->getPath();
        if (!$path) {
            return;
        }

        /** @var UniformResourceLocator $locator */
        $locator = $this->getGrav()['locator'];
        $locator->clearCache();

        $pathname = $filesystem->pathname($filename);

        // Get base name of the file.
        [$base, $ext,,] = $this->getFileParts($basename);
        $name = "{$pathname}{$base}.{$ext}";

        // Remove file and all all the associated metadata.

View on GitHub (pinned to 6040efed04)

When it happens

Trigger: Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:350 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17). Data as JSON: /api/errors/4d519d1343c76c30. Report an issue: GitHub.