79206467

Date: 2024-11-20 09:10:38
Score: 1
Natty:
Report link

It may not be exact answer to you question, we don't know what code is inside controller but few things worth checking:

Type of response that comes from ReportController and what headers there are. eg, taken from domPDF we are using in our project: `

public function stream(string $filename = 'document.pdf'): Response
{
    $output = $this->output();

    return new Response($output, 200, [
        'Content-Type' => 'application/pdf',
        'Content-Disposition' => 'inline; filename="'.$filename.'"',
    ]);
}`

Another solution can be response()->download() or response()->streamDownload() Documented here:

https://laravel.com/docs/10.x/responses#file-downloads

And if the file comes from the API, you might need this too:

https://www.npmjs.com/package/js-file-download

Lastly, I'm not sure if it's possible to download file same time using useForm helper(haven't tested it myself), so you might need to fallback for router.post() of axios/fetch requests.

Cheers.

Reasons:
  • Blacklisted phrase (1): Cheers
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Paweł Górowicz