Seehttps://laravel.com/docs/10.x/filesystem#retrieving-files
And https://laravel.com/docs/10.x/responses#file-downloads
I suggest looking this up in symfony code.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
UPDATE: Looks like the browser does that automatically for PDF files, not for images
--- original post ---
Hello,
I have a link that opens in a new tab:
<a href="/page-preview/{{ $page_id }}" target="_blank">View File</a>
And I then provide a file response to view the file in the browser:
// in controller
{
// get $pathToFile from db
return response()->file($pathToFile);
}
Now I see the file in the browser in the new tab and it's OK. However sometimes in other websites, when I click a link that opens an image or file in a new tab, it opens in some dedicated page that gives more options like downloading, printing etc (so I think it's the print preview but I'm not sure).
How can I do that (if at all)?
Thanks
Please or to participate in this conversation.