How can PHP be used to move files within a server directory?

To move files within a server directory using PHP, you can utilize the `rename()` function. This function takes two parameters: the current file path and the new file path. Make sure to provide the full server path for both parameters to ensure the files are moved correctly.

$oldFilePath = '/path/to/current/file.txt';
$newFilePath = '/path/to/new/file.txt';

if(rename($oldFilePath, $newFilePath)){
    echo "File moved successfully";
} else {
    echo "Error moving file";
}