moveFile.php
Table of Contents
Functions
- moveFile() : bool
- Moves (or renames) a single file to a destination path.
Functions
moveFile()
Moves (or renames) a single file to a destination path.
moveFile(string $source, string $destination[, bool $overwrite = true ][, bool $createDirectory = true ]) : bool
Shares the destination semantics of copyFile():
- the source is validated with assertFile() (must exist and be readable);
- if
$destinationis an existing directory, the file is moved inside it, keeping the source basename; - when
$overwriteisfalse, an existing destination raises a FileException; - the destination's parent directory is created on demand when
$createDirectoryistrue.
The move is performed with rename() (atomic on the same filesystem). When the
source and destination live on different filesystems, rename() cannot span
devices, so the function transparently falls back to copyFile() + deleteFile().
Parameters
- $source : string
-
Path to the source file to move.
- $destination : string
-
Destination file path, or an existing directory to move into.
- $overwrite : bool = true
-
Whether to overwrite an existing destination file (default:
true). - $createDirectory : bool = true
-
Whether to create the destination directory if missing (default:
true).
Tags
Return values
bool —Returns true on success.