Home >> Snippet List >> Snippet

Name
Copy File From Server
Description
This will retrieve a text file from a remote server and write it to yours
PHP Snippet
<?PHP
 
$inputfile = FOPEN("http://the-remote-server.com/inputfile.txt", "r");
$outputfile = FOPEN("outputfile.txt", "w");
ECHO "File opened...";
$data = '';
 
WHILE (!FEOF($inputfile)) {
  $data .= FREAD($inputfile, 8192);
}
 
ECHO "Data read...";
FWRITE($outputfile, $data);
ECHO "transfered data";
FCLOSE ($inputfile);
FCLOSE ($outputfile);
 
ECHO "Done.";
 
?>