note 86107 modified in function.ftp-fget by danbrown
| From: | danbrown@php.net | Date: | Fri, 03 Oct 2008 17:50:40 +0000 |
| Subject: | note 86107 modified in function.ftp-fget by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145024@lists.php.net to get a copy of this message | ||
<?php
/**
* Function returns contents via FTP connection and returns it as string (right version...)
*/
function ftp_get_contents ($conn_id, $filename) {
//Create temp handler:
$tempHandle = fopen('php://temp', 'r+');
//Get file from FTP:
if (@ftp_fget($conn_id, $tempHandle, $filename, FTP_ASCII, 0)) {
rewind($tempHandle);
return stream_get_contents($tempHandle);
} else {
return false;
}
}
?>
--was--
/**
* Function returns contents via FTP connection and returns it as string (right version...)
*/
function ftp_get_contents ($conn_id, $filename) {
//Create temp handler:
$tempHandle = fopen('php://temp', 'r+');
//Get file from FTP:
if (@ftp_fget($conn_id, $tempHandle, $filename, FTP_ASCII, 0)) {
rewind($tempHandle);
return stream_get_contents($tempHandle);
} else {
return false;
}
}
http://php.net/manual/en/function.ftp-fget.php