Copiare un file dall’esterno nel nostro server con php

 
< ?php
// this must be done somehow how you want
$filename = 'test.txt';
 
$handle = fopen("http://www.foo.com/", "rb");
if($handle){
  $somecontent = stream_get_contents($handle);
  fclose($handle);
 
  $handle = fopen($filename, 'wb');
  if($handle){
    if (fwrite($handle, $somecontent) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
    }
    echo "Success, wrote ($somecontent) to file ($filename)";
    fclose($handle);
  }else{
     echo "Cannot create file ($filename)";
     exit;
  }
}
?>