Pony.fm/app/Library/File.php

31 lines
875 B
PHP
Raw Normal View History

2015-08-30 15:01:12 +02:00
<?php
/**
* File.
2015-08-30 15:01:12 +02:00
*
* Note: Remember to remove the "File" alias in APP_DIR/config/application.php
*
* @author Phill Sparks <me@phills.me.uk>
*/
class File extends \Illuminate\Support\Facades\File
{
public static function inline($path, $mime, $name = null)
{
if (is_null($name)) {
$name = basename($path);
}
$response = response(static::get($path));
2015-08-30 15:01:12 +02:00
$response->header('Content-Type', $mime);
$response->header('Content-Disposition', 'inline; filename="'.$name.'"');
2015-08-30 15:01:12 +02:00
$response->header('Content-Transfer-Encoding', 'binary');
$response->header('Expires', 0);
$response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$response->header('Pragma', 'public');
$response->header('Content-Length', filesize($path));
return $response;
}
}