octobercms/october · error · ApplicationException

editor::lang.filesystem.error_moving_file

Error message

editor::lang.filesystem.error_moving_file

What it means

Thrown by editorMoveFilesOrDirectories when @File::move() returns false for a regular file (lines 208-214). Message: 'Error moving file :file'. All preconditions passed, so this is an OS-level failure: the PHP user cannot write the destination directory (or rename across devices where applicable), the source file is locked, or a mount prevents the operation.

Source

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

            $originalFullPath = $basePath.'/'.$path;
            $newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;
            $safeDir = $basePath;

            if ($originalFullPath == $newFullPath) {
                continue;
            }

            if ((is_file($originalFullPath) && is_file($newFullPath))
                || (is_dir($originalFullPath) && is_dir($newFullPath))) {
                throw new ApplicationException(Lang::get(
                    'editor::lang.filesystem.destination_exists',
                    ['name' => $basename]
                ));
            }

            if (is_file($originalFullPath)) {
                if (!@File::move($originalFullPath, $newFullPath)) {
                    throw new ApplicationException(Lang::get(
                        'editor::lang.filesystem.error_moving_file',
                        ['file' => $basename]
                    ));
                }
            }
            elseif (is_dir($originalFullPath)) {
                if (!@File::copyDirectory($originalFullPath, $newFullPath)) {
                    throw new ApplicationException(Lang::get(
                        'editor::lang.filesystem.error_moving_directory',
                        ['dir' => $basename]
                    ));
                }

                if (strpos($originalFullPath, '../') !== false) {
                    throw new ApplicationException(Lang::get(
                        'editor::lang.filesystem.error_deleting_directory',
                        ['dir' => $basename]
                    ));

View on GitHub (pinned to b608633a7e)

Solutions

  1. chown/chmod the destination directory so the PHP user can write (move needs write on the target dir)
  2. Verify the source file is not locked (close editors/lsof) and the volume is read-write
  3. Retry after fixing permissions — the failing file has not been moved, earlier files in the batch may have
  4. Check whether a partial batch already moved some files; reconcile before re-running

Example fix

# before: destination dir root-owned
$ sudo chown -R www-data:www-data themes/demo/assets/img
# retry the move in the Editor
Defensive patterns

Strategy: try-catch

Validate before calling

$newFullPath = rtrim($destinationFullPath, '/').'/'.basename($path);
if (!is_writable($destinationFullPath) || !is_writable($assetsBase.'/'.$path)) {
    // File::move needs write on both directory entries — fix perms first
}

Try / catch

use October\Rain\Exception\ApplicationException;

try {
    if (!@File::move($originalFullPath, $newFullPath)) {
        throw new ApplicationException(Lang::get('editor::lang.filesystem.error_moving_file', ['file' => $basename]));
    }
} catch (ApplicationException $e) {
    Log::warning('asset move failed', ['file' => $basename]);
    throw $e; // UI shows the localized message; earlier batch items already moved
}

Prevention

When it happens

Trigger: command_onAssetMove where the destination directory was auto-created with 0755 by a process other than the webserver user, or a pre-existing destination folder with restrictive ownership; Windows locked source file; read-only destination mount.

Common situations: Destination subfolders created by root deploys; permission drift between theme subdirectories; containerized setups with mixed volume ownership; source asset open in another program on Windows.

Related errors


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