Skip to content

Instantly share code, notes, and snippets.

@fhdalikhan
Created January 28, 2021 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhdalikhan/a26c86865c33ace95dfffe5c694393f6 to your computer and use it in GitHub Desktop.
Save fhdalikhan/a26c86865c33ace95dfffe5c694393f6 to your computer and use it in GitHub Desktop.
Copy file from another server using PHP
<?php
$file = 'http://domain/all.zip';
$saveFileWithName = "backup.zip";
$newfile = $_SERVER['DOCUMENT_ROOT'] . '/' . $saveFileWithName;
if (copy($file, $newfile)) {
echo "Copy success!";
} else {
echo "Copy failed.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment