2017 © Pedro Peláez
 

library http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

image

shemgp/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  • Thursday, May 24, 2018
  • by shemgp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 17 Versions
  • 20 % Grown

The README.md

HTTP send file

Sends a file with support for (multiple) range requests. It is able to throttle the download. It is quite small and simple., (*1)

This class resembles the php http_send_file from PHP pecl, (*2)

See:, (*3)

http://php.net/manual/en/function.http-send-file.php, (*4)

Install, (*5)

With composer add to your "require" section:, (*6)

composer require shemgp/http-send-file

Usage example:, (*7)


use diversen\sendfile; $s = new sendfile(); // if you don't set type - we will try to guess it $s->contentType('application/epub+zip'); // if you don't set disposition (file name user agent will see) // we will make a file name from file $s->contentDisposition('test.epub'); // chunks of 40960 bytes per 0.1 secs // if you don't set this then the values below are the defaults // approx 409600 bytes per sec $s->throttle(0.1, 40960); // file $file = '/some/dir/test.epub'; // send the file try { $s->send($file); } catch (\Exception $e) { echo $e->getMessage(); }

So you could just do like this:, (*8)


use diversen\sendfile; $s = new sendfile(); // file $file = '/some/dir/test.epub'; // send the file try { $s->send($file); } catch (\Exception $e) { echo $e->getMessage(); } // but check the headers if it is not // working as expected as the guessing // of content-type does not always work // correctly.

Without sending content-disposition header:, (*9)


// without sending content-disposition header // 2. param = false try { $s->send($file, false); } catch (\Exception $e) { echo $e->getMessage(); }

Send file as inline:, (*10)


// Send as inline // 3. param = false try { $s->send($file, true, false); } catch (\Exception $e) { echo $e->getMessage(); }

Credits

Much of the code is taken (and rewritten) from here:, (*11)

http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/, (*12)

The process is nicely explained here:, (*13)

http://www.media-division.com/the-right-way-to-handle-file-downloads-in-php/, (*14)

MIT © Dennis Iversen, Shem Pasamba, (*15)

The Versions

24/05 2018

dev-master

9999999-dev http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

MIT

file http download throttle resume

24/05 2018

v2.0.4

2.0.4.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

MIT

file http download throttle resume

13/09 2017

v2.0.3

2.0.3.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

MIT

file http download throttle resume

13/09 2017

v2.0.2

2.0.2.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

MIT

file http download throttle resume

13/09 2017

v2.0.1

2.0.1.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

13/09 2017

v2.0.0

2.0.0.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

23/11 2016

v1.0.91

1.0.91.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is also able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

13/09 2016

dev-revert-6-master

dev-revert-6-master http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

25/08 2016

v1.0.9

1.0.9.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

05/08 2015

v1.0.7

1.0.7.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

05/08 2015

v1.0.8

1.0.8.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

05/08 2015

v1.0.6

1.0.6.0 http://github.com/diversen/http-send-file

Sends a file to a client, with support for (multiple) range requests. It is able to throttle the download.

  Sources   Download

BSD-3-Clause

file http download throttle resume

08/05 2015

v1.0.5

1.0.5.0

  Sources   Download

01/04 2015

v1.0.4

1.0.4.0

  Sources   Download

01/04 2015

v1.0.3

1.0.3.0

  Sources   Download

02/03 2015

v1.0.2

1.0.2.0

  Sources   Download

02/03 2015

v1.0.1

1.0.1.0

  Sources   Download