Simple php function to download files like pdf, xml, doc and images from a url and save to given path in server
In this $source_url holds the path of file to download and $destination_path holds the path to save file.
function download_remote($source_url , $destination_path) {
$file = fopen( $destination_path , 'w+');
$file_handle = fopen($source_url , "rb");
while (!feof($file_handle)) {
$file_contents = fread($file_handle, 8192);
fwrite($file , $file_contents);
}
fclose($file_handle);
fclose($file);
}
No comments:
Post a Comment