Answers for "laravel afficher fichier"

0

laravel afficher fichier

<embed
       src="{{ action('DocumentController@getDocument', ['id'=> $document->id]) }}"
       style="width:600px; height:800px;"
       frameborder="0"
>
Posted by: Guest on December-31-2020
0

laravel afficher fichier

public function getDocument($id)
{
       $document = Document::findOrFail($id);

       $filePath = $document->file_path;

       // file not found
       if( ! Storage::exists($filePath) ) {
         abort(404);
       }

       $pdfContent = Storage::get($filePath);

       // for pdf, it will be 'application/pdf'
       $type       = Storage::mimeType($filePath);
       $fileName   = Storage::name($filePath);

       return Response::make($pdfContent, 200, [
         'Content-Type'        => $type,
         'Content-Disposition' => 'inline; filename="'.$fileName.'"'
       ]);
}
Posted by: Guest on December-31-2020

Browse Popular Code Answers by Language