How To Copy a File

Q

How To Copy a File? - PHP Script Tips - Working with Directoris and Files

✍: FYIcenter.com

A

If you have a file and want to make a copy to create a new file, you can use the copy() function. Here is a PHP script example on how to use copy():

<?php
unlink("/temp/myPing.exe");
copy("/windows/system32/ping.exe", "/temp/myPing.exe");
if (file_exists("/temp/myPing.exe")) {
  print("A copy of ping.exe is created.\n"); 
}
?>

This script will print:

A copy of ping.exe is created.

2007-04-23, 4300👍, 0💬