mhndev/slim-file-response

0.1.1 2017-02-23 22:36 UTC

This package is auto-updated.

Last update: 2024-09-06 08:56:11 UTC


README

使用此包,您可以轻松实现HTTP文件响应。所以FileResponse类的作用是设置文件响应所需的HTTP头信息,而且getResponse方法有一个可选的第三个参数,当您希望HTTP客户端将文件保存为不同于服务器上存储名称的名称时,可以提供该参数。

示例用法

$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');
});