PHP code example of simotod / slim-download
1. Go to this page and download the library: Download simotod/slim-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/ */
simotod / slim-download example snippets
$app = new \Slim\Slim();
$app->get('/download', function () use ($app) {
//Do some stuff here
$filepath = "/path/to/file";
$app->view(new \SimoTod\SlimDownload\DownloadView());
$app->render($filepath);
});
$app->run();
$app->get('/download', function () use ($app) {
//Do some stuff here
$filepath = "/path/to/pdf";
$data = array();
$data["CONTENT_TYPE"] = "application/pdf";
$data["FILENAME"] = "sample.pdf";
$app->view(new \SimoTod\SlimDownload\DownloadView());
$app->render($filepath);
});