streaming downloads

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

streaming downloads

Postby vip32 » Fri Oct 11, 2013 8:08 pm

I have not found any documentation and with my attempts I have not got my desired outcome. I am not sure if $sftp-get() can be streamed directly out to the browser before the full file has been downloaded. I am looking this feature so a user downloading a large file from a remote server over a slow connection will not be given a script or even browser timeout. Ideally if the download can be flushed to the browser as it is received by php. I was able to get a result similar to what I am looking using the php ssh2.sftp module but if possible I would like to use only 1 method if possible.
Posts: 1
Joined: Fri Oct 11, 2013 7:54 pm

Re: streaming downloads

Postby TerraFrost » Sat Oct 12, 2013 6:49 pm

You can download in chunks. eg. download and output the first 1,000 bytes, flush the output, download the next 1,000 bytes, etc.


Code: Select all
echo $sftp->get('filename.ext', false, 0, 1000);
echo $sftp->get('filename.ext', false, 1000, 1000);
Legendary Guard
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 2 guests