Copying a File to a New Location

Problem

You want to copy a file to a different location.

You know you can use PHP's copy() function, but want to use Laravel's File facade.

Solution

Use the File::copy() method.

if ( ! File::copy($file, $dest))
{
    die("Couldn't copy file");
}

Discussion

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

comments powered by Disqus