I'm new in laravel and I use phpword to edit a word doc file.
I want once I save it I can display it in read only permission.
I want to display it directly without forcing download.
I tried this code but it forces the download.
Here is my code :
public function create()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
//Ajouter l'image
$section->addImage(
'C:\wamp\www\Stage_2\public\images\mobilis256.png',
array(
'width' => 100,
'height' => 100,
'marginTop' => -1,
'marginLeft' => -1,
'wrappingStyle' => 'behind'
));
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
try {
$objWriter->save(storage_path('helloWorld.docx'));
}catch(Exception $e)
{}
$filename = 'helloWorld.docx';
$path = storage_path($filename);
return Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/docx',
'Content-Disposition' => 'inline; filename="'.$filename.'"'
]);
}
i tried also
return response()->file(storage_path('helloWorld.docx'));
but always the same result.
what should I do, and how can i disply it in read only permission?