I need help with creation of custom FTP wrapper in PHP.
I used
$h=fopen('ftp://....');
But this doesn't work well with all FTP servers (sometimes problems with active/passive mode) and i can not control this with the wrapper.
I use functions from http://php.net/manual/en/book.ftp.php and all works fine. I have problems only with download with PHP FTP wrapper.
I need to use wrapper because i don't want to store downloaded file to the disk. I read part of a file from a stream and then output to a user browser.
So i want to create custom FTP wrapper in PHP. And best of all if it is based on functions from there http://php.net/manual/en/book.ftp.php .
I see example there http://php.net/manual/en/function.ftp-fget.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']);
}
But this is not good as it saves full file to the disk and only after this i can read from the local file.
DO you know something like this but allows me to read file with portions from FTP server without caching full file locally?
Thanks.