Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

How to stream file to the "print preview" page on the browser?

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

0 likes
1 reply

Please or to participate in this conversation.