Skip to content

Instantly share code, notes, and snippets.

@sarathlal-old
Created July 29, 2015 10:01
Show Gist options
  • Save sarathlal-old/fe93ca2f4e8a1b8ca242 to your computer and use it in GitHub Desktop.
Save sarathlal-old/fe93ca2f4e8a1b8ca242 to your computer and use it in GitHub Desktop.
Transfer files from server to server using PHP `copy()` function.
<?php
// Insert this file on server and go to the path from browser.
set_time_limit(0); //Unlimited max execution time
/* Source File URL */
$remote_file_url = 'http://origin-server-url/files.zip';
/* New file name and path for this file */
$local_file = 'files.zip';
/* Copy the file from source url to server */
$copy = copy( $remote_file_url, $local_file );
/* Add notice for success/failure */
if( !$copy ) {
echo "Doh! failed to copy $file...\n";
}
else{
echo "WOOT! success to copy $file...\n";
}
?>
@lwoods
Copy link

lwoods commented Aug 18, 2022

Doesn't work if the source is REALLY a remote. Permissions will block it every time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment