PHP code example of karelwintersky / arris.php-file-download

1. Go to this page and download the library: Download karelwintersky/arris.php-file-download library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

karelwintersky / arris.php-file-download example snippets


use Arris\Toolkit\FileDownload;

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

$file = fopen("/path/to/file.pdf", "rb"); // либо tmpfile(), php://memory и т.п.
$fileDownload = FileDownload::createFromResource($file);
$fileDownload->sendDownload("download.pdf");

$fileDownload = new FileDownload($file, "/path/to/file.pdf");

$content = "содержимое файла";
$fileDownload = FileDownload::createFromString($content);
$fileDownload->sendDownload("download.txt");

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

/* рисуем содержимое PDF ... */

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

public function sendDownload(string $filename = '', bool $forceDownload = true, bool $exit = true)

$fileDownload = FileDownload::createFromFilePath("/path/to/report.pdf");

// скачать как «Отчёт.pdf», не завершая скрипт
$fileDownload->sendDownload("Отчёт.pdf", true, false);
bash
composer