Skip to content

Instantly share code, notes, and snippets.

@r37r0m0d3l
Created September 12, 2012 12:20
Show Gist options
  • Save r37r0m0d3l/3706260 to your computer and use it in GitHub Desktop.
Save r37r0m0d3l/3706260 to your computer and use it in GitHub Desktop.
File download
<?php
function download_file($url, $newfname)
{
if (($file = fopen($url, 'rb')))
if (($newf = fopen($newfname, 'wb')))
while (!feof($file))
fwrite($newf, fread($file, 8192), 8192);
if ($file)
fclose($file);
if (isset($newf))
{
fclose($newf);
return true;
}
else return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment