PHP Copy a file from one server to another

Опубликовано: 22 Октябрь 2024
на канале: Len Farneth
19,342
65

A really easy way to copy a file from one server to another. Using the code below. simply put any file you want to copy on the source line. and name the destination whatever you want.


(close the following in php tags)

$source =("http://yourserver.com/file.txt");
$destination = 'clonefile.txt';

$data = file_get_contents($source);

$handle = fopen($destination, "w");
fwrite($handle, $data);
fclose($handle);