PHP: How to Transfer File from Server to Server Online using PHP?

// you can increase following limits according to size of remote file.
ini_set('max_execution_time', '30000');
ini_set('memory_limit', '30000');

/* Source File URL */
$remote_file_url = 'http://www.Your_remote_url.com/Your_File.zip';
 
/* New file name and path for this file */
$local_file = 'Your_File.zip';
 
/* Copy the file from source url to server */
$copy = copy( $remote_file_url, $local_file );
 
/* Add notice for success/failure */
if( !$copy ) {
    echo "Copy Failed\n";
}
else{
    echo " File is successfully copied.\n";
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *