apfelbox/php-file-download 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

apfelbox/php-file-download

最新稳定版本:v2.1

Composer 安装命令:

composer require apfelbox/php-file-download

包简介

A library to help with creating downloads for files in PHP

关键字:

README 文档

README

A class to help with creating downloads for files in PHP.

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.

Usage

The examples assume, that you have included the namespace:

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):

$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");

统计信息

  • 总下载量: 184.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 82
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 71
  • Watchers: 3
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-01-21