note 68844 added to function.ftp-get

From: Date: Sat, 12 Aug 2006 22:05:24 +0000
Subject: note 68844 added to function.ftp-get
Groups: php.notes 
Request: Send a blank email to php-notes+get-115847@lists.php.net to get a copy of this message
Hello everybody, If someone will try to download files to the same local file (some temporary file), like shown here: <?php foreach ($files as $key=>$path) { ... $result = ftp_get($ftpConnId, 'temp.tmp', $path, FTP_BINARY); ... } ?> please take in consideration the fact that you will have big problems with downloading (getting) hole files. In other words ‘temp.tmp’ file always will have the same size equal to first downloaded file despite the real size of downloading file. I have not idea what is the reason! If someone will think that problem is just in getting proper file size (which you will get using filssize() function) he will be mistaken. The download file’s size is not equal to source file’s size materially, that means fflush() function will not solve the problem (I have tried this as well). Finally the solution was founded: before downloading a file you will need to delete local file if such exist (‘temp.tmp’). So working code will look like: <?php foreach ($files as $key=>$path) { ... if (file_exists('temp.tmp')) { unlink('temp.tmp'); } $result = ftp_get($ftpConnId, 'temp.tmp', $path, FTP_BINARY); ... } ?> Good luck in scripting :-) Vitali Simsive ---- Server IP: 212.72.145.157 Probable Submitter: 212.72.146.171 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-get.php Edit -- https://master.php.net/note/edit/68844 Del: integrated -- https://master.php.net/note/delete/68844/integrated Del: useless -- https://master.php.net/note/delete/68844/useless Del: bad code -- https://master.php.net/note/delete/68844/bad+code Del: spam -- https://master.php.net/note/delete/68844/spam Del: non-english -- https://master.php.net/note/delete/68844/non-english Del: in docs -- https://master.php.net/note/delete/68844/in+docs Del: other reasons-- https://master.php.net/note/delete/68844 Reject -- https://master.php.net/note/reject/68844 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115847) next »