$url = 'http://www.server.com/file.ext';
$file = basename($url);
$contents = file_get_contents($url); // mengambil konten dalam bentuk string (source code).
if ($contents) {
$fh = fopen($file, 'w'); // buka file dengan mode tulis. kosongkan file dan letakkan pointer di awal. jika file tidak ada, maka buat.
fwrite($fh, $contents); // tulis string ke file.
fclose($fh); // tutup file.
echo 'File berhasil disimpan. Download: <a href="'.$file.">'.$file.'</a>';
}
else {
echo 'Gagal';
}