0
我试图在控制器中下载文件,但在控制台中,我只看到了一堆真正的奇怪字符,而不是下载框。我正在关注这个主题Symfony2 - Force file download。symfony - 下载文件
不知道发生了什么...试图找到最简单的解决方案。 这里是我的代码:
$response = new Response(file_get_contents($file->realPath), 200, array(
'Content-Type' => $file->mimeType,
'Content-Length' => filesize($file->realPath),
'Content-Disposition' => 'attachment; filename=' . $file->name,
));
$response->send();
我甚至试图用与报头中的最基本的例子()和ReadFile的()。 我的服务器需要特殊配置吗?干杯。