Home / PHP Tips Generated By ChatGPT / Copying a File in PHP Duplicate a file using copy(), providing a source and a destination. Source Code if (copy('source.txt', 'destination.txt')) { echo "File copied successfully."; } else { echo "File copy failed."; }