【发布时间】:2016-10-17 10:50:49
【问题描述】:
动态生成下载(在我的情况下是 .txt 文件)的最佳方式是什么?我的意思是之前没有将文件存储在服务器上。为了理解这里是我需要完成的事情:
public function getDesktopDownload(Request $request){
$txt = "Logs ";
//offer the content of txt as a download (logs.txt)
$headers = ['Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="test.txt"'), 'Content-Length' => sizeof($txt)];
return Response::make($txt, 200, $headers);
}
【问题讨论】:
标签: php download header laravel-5.3 on-the-fly