PHP将文件从一个目录复制到另一个目录会引发错误

I have two directories I am using, where I want to make a copy of the file in a different directory.

$dest = "/home/********/public_html/$userUName/SharedFiles/";
            $source = "/home/********/public_html/$username/$value";
            if(file_exists($dest))
            {
                //echo $source;
                //echo $dest;
                copy($source, $dest);
            }

$source and $dest are definitely getting the right values required, but it's throwing an error

Warning: copy(/home/********/public_html/johnny/SharedFiles/) [function.copy]: failed to open stream: Is a directory in /home/********/public_html/MainHomescreen.php on line 380

which is the copy line.

Have been through many options to fix it by googling. Have checked file permissions, as far as I can see I've got everything in the right place, so have come to a dead end of where I've gone wrong!

PHP copy function is used to copy Files not Directories. Your destination is a Directory, because it ends with '/' .

To solve your problem, you must also add the file name to be created:

$dest = "/home/********/public_html/$userUName/SharedFiles/SomeNewFile.txt";

This is also true for the source.

Good luck,