laravel afficher fichier

Solutions on MaxInterview for laravel afficher fichier by the best coders in the world

showing results for - "laravel afficher fichier"
Mariangel
02 Nov 2017
1<embed
2       src="{{ action('DocumentController@getDocument', ['id'=> $document->id]) }}"
3       style="width:600px; height:800px;"
4       frameborder="0"
5>
Fabio
23 Oct 2019
1public function getDocument($id)
2{
3       $document = Document::findOrFail($id);
4
5       $filePath = $document->file_path;
6
7       // file not found
8       if( ! Storage::exists($filePath) ) {
9         abort(404);
10       }
11
12       $pdfContent = Storage::get($filePath);
13
14       // for pdf, it will be 'application/pdf'
15       $type       = Storage::mimeType($filePath);
16       $fileName   = Storage::name($filePath);
17
18       return Response::make($pdfContent, 200, [
19         'Content-Type'        => $type,
20         'Content-Disposition' => 'inline; filename="'.$fileName.'"'
21       ]);
22}
similar questions
queries leading to this page
laravel afficher fichier