note 84311 added to function.ssh2-sftp
| From: | basweerman at osu1 dot php dot net | Date: | Tue, 08 Jul 2008 22:13:03 +0000 |
| Subject: | note 84311 added to function.ssh2-sftp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141282@lists.php.net to get a copy of this message | ||
I changed the read function to:
public function receiveFile($remote_file, $local_file)
{
$sftp = $this->sftp;
$stream = @fopen("ssh2.sftp://$sftp$remote_file", 'r');
if (! $stream)
throw new Exception("Could not open file: $remote_file");
$size = $this->getFileSize($remote_file);
$contents = '';
$read = 0;
$len = $size;
while ($read < $len && ($buf = fread($stream, $len - $read))) {
$read += strlen($buf);
$contents .= $buf;
}
file_put_contents ($local_file, $contents);
@fclose($stream);
}
public function getFileSize($file){
$sftp = $this->sftp;
return filesize("ssh2.sftp://$sftp$file");
}
----
Server IP: 92.48.74.199
Probable Submitter: 217.36.79.45
----
Manual Page -- http://www.php.net/manual/en/function.ssh2-sftp.php
Edit -- https://master.php.net/note/edit/84311
Del: integrated -- https://master.php.net/note/delete/84311/integrated
Del: useless -- https://master.php.net/note/delete/84311/useless
Del: bad code -- https://master.php.net/note/delete/84311/bad+code
Del: spam -- https://master.php.net/note/delete/84311/spam
Del: non-english -- https://master.php.net/note/delete/84311/non-english
Del: in docs -- https://master.php.net/note/delete/84311/in+docs
Del: other reasons-- https://master.php.net/note/delete/84311
Reject -- https://master.php.net/note/reject/84311
Search -- https://master.php.net/manage/user-notes.php