dcat-admin
dcat-admin copied to clipboard
Error: Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in file vendor\dcat\laravel-admin\src\Http\Middleware\Pjax.php on line 72
Laravel Version: 8.73.1 PHP Version: 7.4.16 Dcat Admin Version: 2.1.5-beta
Description:
On one of the pages I have download links to non-image files like .txt, the HTML code like this:
<a href="https://my.website/admin/storage/projects/2/192309637test2.txt" class="attchment-link inline-block pr-2" onclick="return(true);">
<i class="fa fa-paperclip"></i>
<span class="text-primary">192309637test2.txt</span>
</a>
When clicking the link, I can download and save the file, but the following error is displayed in the console:
GET https://my.website/admin/storage/projects/2/192309637test2.txt?_pjax=%23pjax-container 500 (Internal Server Error) Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in file vendor\dcat\laravel-admin\src\Http\Middleware\Pjax.php on line 72
checked the code on line 72:
$response->header(
'X-PJAX-URL',
$request->getRequestUri()
);
According to google search, the code should be changed to:
$response->headers->set($key, $value);
Steps To Reproduce:
The same problem.
when use response()->download($path)
can trigger.
In the download function the response
is instance of BinaryFileResponse.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.