Moving a File to a New Location

Problem

You want to move a file to a different location.

Solution

Use the File::move() method.

if ( ! File::move($oldfile, $newfile))
{
    die("Couldn't rename file");
}

Discussion

This is a wrapper on PHP's rename() function.

Use it to move files to different directories, to different drives, or to rename a file.

comments powered by Disqus