note 60718 added to function.fopen

From: Date: Sun, 15 Jan 2006 03:58:48 +0000
Subject: note 60718 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-101774@lists.php.net to get a copy of this message
download: i need a function to simulate a "wget url" and do not buffer the data in the memory to avoid thouse problems on large files: <?php function download($file_source, $file_target) { $rh = fopen($file_source, 'rb'); $wh = fopen($file_target, 'wb'); if ($rh===false || $wh===false) { // error reading or opening file return true; } while (!feof($rh)) { if (fwrite($wh, fread($rh, 1024)) === FALSE) { // 'Download error: Cannot write to file ('.$file_target.')'; return true; } } fclose($rh); fclose($wh); // No error return false; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60718 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60718&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60718&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101774) next »