在symfony中下载文件
我正在尝试将当前html页面作为symfony中的文件下载: 我的小树枝:在symfony中下载文件,symfony,Symfony,我正在尝试将当前html页面作为symfony中的文件下载: 我的小树枝: <a href="{{ path('polytech_skills_evaluations_export', {'idssoccasion': ssoccasion.id, 'idevalue':user.id}) }}" >Exporter </a> Warning: mime_content_type failed to open stream: Invalid argument 我得到的
<a href="{{ path('polytech_skills_evaluations_export', {'idssoccasion': ssoccasion.id, 'idevalue':user.id}) }}" >Exporter </a>
Warning: mime_content_type failed to open stream: Invalid argument
我得到的错误:
<a href="{{ path('polytech_skills_evaluations_export', {'idssoccasion': ssoccasion.id, 'idevalue':user.id}) }}" >Exporter </a>
Warning: mime_content_type failed to open stream: Invalid argument
500内部服务器错误-ContextErrorException在这种情况下,最好的解决方案是保存(甚至暂时保存页面),然后强制下载:
file_put_contents('page.html', $content);
然后,您可以使用如下代码下载该文件:
// Create response et hydrate headers
$response = new Response();
$response->setContent(file_get_contents('page.html'));
$response->headers->set('Content-Type', 'text/html');
$response->headers->set('Content-disposition', 'filename=page.html');
// Return response
return $response;
理工学校:)
谢谢你的反馈我阅读了建议的解决方案,这是我用过的,但是我认为它不能把$HTML作为一个文件,错误变成:文件。“理工技能……”。。。。。不存在完美!我是理工学院的校友;)不要忘记指出解决方案是由+1或验证来帮助社区的。谢谢,我没弄明白!!我怎样才能表明这一点?