note 86104 added to function.fstat
| From: | broom at alturnanetworks dot com | Date: | Fri, 03 Oct 2008 10:21:38 +0000 |
| Subject: | note 86104 added to function.fstat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145011@lists.php.net to get a copy of this message | ||
Another ftp_get_contents() approach, using a temperary stream handler. Returns file contents of
remote file as string.
function ftp_get_contents ($conn_id, $remote_filename) {
//Create temp handler:
$tempHandle = fopen('php://temp', 'r+');
//Get file from FTP assuming that it exists:
ftp_fget($conn_id, $tempHandle, $remote_filename, FTP_ASCII, 0));
//Getting detailed stats to check filesize:
$fstats = fstat($tempHandle);
return fread($tempHandle, $fstats['size']);
}
(It is recommended to add some error handling)
----
Server IP: 213.249.64.162
Probable Submitter: 212.45.32.222 (proxied: 83.247.62.56)
----
Manual Page -- http://www.php.net/manual/en/function.fstat.php
Edit -- https://master.php.net/note/edit/86104
Del: integrated -- https://master.php.net/note/delete/86104/integrated
Del: useless -- https://master.php.net/note/delete/86104/useless
Del: bad code -- https://master.php.net/note/delete/86104/bad+code
Del: spam -- https://master.php.net/note/delete/86104/spam
Del: non-english -- https://master.php.net/note/delete/86104/non-english
Del: in docs -- https://master.php.net/note/delete/86104/in+docs
Del: other reasons-- https://master.php.net/note/delete/86104
Reject -- https://master.php.net/note/reject/86104
Search -- https://master.php.net/manage/user-notes.php