Sunday, October 25, 2015

Using PHP Copy to move files from server to server.

  1. /**
  2.  * Transfer Files Server to Server using PHP Copy
  3.  * @link https://shellcreeper.com/?p=1249
  4.  */
  5.  
  6. /* Source File URL */
  7. $remote_file_url = 'http://origin-server-url/files.zip';
  8.  
  9. /* New file name and path for this file */
  10. $local_file = 'files.zip';
  11.  
  12. /* Copy the file from source url to server */
  13. //$copy = copy( $remote_file_url, $local_file );
  14. $copy = file_put_contents($local_file, fopen($remote_file_url, 'r')); //lihat http://stackoverflow.com/questions/3938534/download-file-to-server-from-url
  15.  
  16. /* Add notice for success/failure */
  17. if( !$copy ) {
  18.     echo "Doh! failed to copy $file...\n";
  19. }
  20. else{
  21.     echo "WOOT! success to copy $file...\n";
  22. }
https://shellcreeper.com/move-files-server-to-server-using-simple-php/