PHP code example of mhndev / slim-file-response
1. Go to this page and download the library: Download mhndev/slim-file-response 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/ */
mhndev / slim-file-response example snippets
$app->get('/test/image',function($request, $response){
$filePath = '/path/to/your/image/file';
return mhndev\slimFileResponse\FileResponse::getResponse($response, $filePath);
});
$app->get('/test/pdf',function($request, $response){
$filePath = '/path/to/your/pdf/file';
return mhndev\slimFileResponse\FileResponse::getResponse($response, $filePath ,'myDocument');
});