note 86106 modified in function.ftp-fget by danbrown
| From: | danbrown@php.net | Date: | Fri, 03 Oct 2008 17:51:12 +0000 |
| Subject: | note 86106 modified in function.ftp-fget by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145025@lists.php.net to get a copy of this message | ||
Another ftp_get_contents approach, using a temperary stream handler. Returns file contents as
string.
<?php
function ftp_get_contents ($conn_id, $filename,
//Create temp handler:
$tempHandle = fopen('php://temp', 'r+');
//Get file from FTP assuming that it exists:
ftp_fget($conn_id, $tempHandle, $filename, FTP_ASCII, 0));
//Getting detailed stats to check filesize:
$fstats = fstat($tempHandle);
return fread($tempHandle, $fstats['size']);
}
?>
--was--
Another ftp_get_contents approach, using a temperary stream handler. Returns file contents as
string.
function ftp_get_contents ($conn_id, $filename,
//Create temp handler:
$tempHandle = fopen('php://temp', 'r+');
//Get file from FTP assuming that it exists:
ftp_fget($conn_id, $tempHandle, $filename, FTP_ASCII, 0));
//Getting detailed stats to check filesize:
$fstats = fstat($tempHandle);
return fread($tempHandle, $fstats['size']);
}
http://php.net/manual/en/function.ftp-fget.php