2017 © Pedro Peláez
 

library php-file-download

A library to help with creating downloads for files in PHP

image

apfelbox/php-file-download

A library to help with creating downloads for files in PHP

  • Thursday, May 21, 2015
  • by apfelbox
  • Repository
  • 3 Watchers
  • 42 Stars
  • 30,736 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 16 Forks
  • 3 Open issues
  • 3 Versions
  • 9 % Grown

The README.md

PHP File Download

A class to help with creating downloads for files in PHP., (*1)

Tip

If you can use direct downloads, you should just use them. This class is for providing downloads of files out of PHP, for example if you want to provide a download to a temporarily created file., (*2)

Usage

The examples assume, that you have included the namespace:, (*3)

use Apfelbox\FileDownload\FileDownload;

Create a download for a file on your file system

$fileDownload = FileDownload::createFromFilePath("/path/to/file.pdf");
$fileDownload->sendDownload("download.pdf");

Create a download for a file via file pointer

$file = /* your file, somewhere opened with fopen() or tmpfile(), etc.. */;
$fileDownload = new FileDownload($file);
$fileDownload->sendDownload("download.pdf");

Create a download for a file via content

$content = "This is the content of the file:";
$fileDownload = FileDownload::createFromString($content);
$fileDownload->sendDownload("download.txt");

For example, you can create downloads for PDF files, generated by Zend (or any other library):, (*4)

$pdf = new Zend_Pdf();
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;

/* draw content in the pdf ... */

$fileDownload = FileDownload::createFromString($pdf->render());
$fileDownload->sendDownload("download.pdf");

The Versions

21/05 2015

dev-master

9999999-dev https://github.com/apfelbox/PHP-File-Download

A library to help with creating downloads for files in PHP

  Sources   Download

BSD-3-Clause

The Requires

 

download

10/02 2014

v2.1

2.1.0.0 https://github.com/apfelbox/PHP-File-Download

A library to help with creating downloads for files in PHP

  Sources   Download

BSD-3-Clause

The Requires

 

download

21/01 2014

v2.0

2.0.0.0 https://github.com/apfelbox/PHP-File-Download

A library to help with creating downloads for files in PHP

  Sources   Download

MIT

The Requires

 

download