Skip to content

Instantly share code, notes, and snippets.

@nguyenbathanh
Last active July 22, 2016 07:36
Show Gist options
  • Save nguyenbathanh/dc1085993842462af01ad02c7c632271 to your computer and use it in GitHub Desktop.
Save nguyenbathanh/dc1085993842462af01ad02c7c632271 to your computer and use it in GitHub Desktop.
function downloadFile($url, $path)
{
$newfname = $path;
$file = fopen ($url, 'rb');
if ($file) {
$newf = fopen ($newfname, 'wb');
if ($newf) {
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
}
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment