Skip to content

Instantly share code, notes, and snippets.

Forked from musamamasood/transfer.php
Last active November 6, 2017 07:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Transfer files to server with publicly accessible zip file with extraction using PHP Copy and PHP ZipArchive. You just have to change the $remote_file_url and then upload this file on destination server and execute the file.
* Transfer Files Server to Server using PHP Copy and PHP ZipArchive
* @link
/* Source File URL */
$remote_file_url = '';
/* New file name and path for this file */
$local_file = '';
/* 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 $local_file\n";
echo "WOOT! Success to copy $local_file...\n";
$zip = new ZipArchive;
$res = $zip->open('');
if ($res === TRUE) {
$path = getcwd() . "/backup/"; //getcwd will get the path of file
echo '<br>Woot! File has been Extracted at: '.$path;
} else {
echo '<br>doh!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment