Can you share the code of your view where you call the route that returns the file.
Mar 22, 2024
4
Level 1
View uploaded file in new window
I am trying to view a file in new window instead of download, but when I click it opens in the same window as my app so I have to click the browser back button to go back to the app can anyone be of help this is the code below. its a PDF file
use Illuminate\Support\Facades\Storage; use Illuminate\Http\Response;
$pathToFile = "C:/xampp/htdocs/project/storage/files/file.pdf"; if(Storage::exists($pathToFile)) { $fileContent = Storage::get($pathToFile);;
$contentType = Storage::mimeType($pathToFile);
return (new Response($fileContent, 200))
->header('Content-Type', $contentType)
->header('Content-Disposition', 'inline');
}
Please or to participate in this conversation.