Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author: unknown
- */
- /**
- * Simulates a "wget url" and do not buffer data in the memory in order
- * to avoid thouse problems on large files.
- *
- * @param string $file_source
- * @param string $file_target
- * @return bool
- */
- function download($file_source, $file_target)
- {
- $rh = fopen($file_source, 'rb');
- $wh = fopen($file_target, 'wb');
- // error reading or opening file
- if ($rh===false || $wh===false) return false;
- while (! feof($rh) )
- {
- // 'Download error: Cannot write to file ('.$file_target.')';
- if (fwrite($wh, fread($rh, 1024)) === FALSE) return false;
- }
- fclose($rh);
- fclose($wh);
- // No error
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement