Handle file_get_contents more gracefully
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
349715576a
commit
67ed0d91c0
1 changed files with 12 additions and 2 deletions
|
@ -9,11 +9,21 @@ class ActionlogController extends Controller
|
||||||
{
|
{
|
||||||
public function displaySig($filename)
|
public function displaySig($filename)
|
||||||
{
|
{
|
||||||
|
// PHP doesn't let you handle file not found errors well with
|
||||||
|
// file_get_contents, so we set the error reporting for just this class
|
||||||
|
error_reporting(0);
|
||||||
|
|
||||||
$this->authorize('view', \App\Models\Asset::class);
|
$this->authorize('view', \App\Models\Asset::class);
|
||||||
$file = config('app.private_uploads').'/signatures/'.$filename;
|
$file = config('app.private_uploads').'/signatures/'.$filename;
|
||||||
$filetype = Helper::checkUploadIsImage($file);
|
$filetype = Helper::checkUploadIsImage($file);
|
||||||
$contents = file_get_contents($file);
|
|
||||||
|
|
||||||
return Response::make($contents)->header('Content-Type', $filetype);
|
$contents = file_get_contents($file, false, stream_context_create(['http' => ['ignore_errors' => true]]));
|
||||||
|
if ($contents === false) {
|
||||||
|
\Log::warn('File '.$file.' not found');
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return Response::make($contents)->header('Content-Type', $filetype);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue