return response ()->download ($pathToFile); 调用这个函数没反应?
代码
/**
* 导出excel
*/
public function exportExl()
{
$result = Excel::download(new InvoicesExport, 'invoices.xlsx');
$absPath = $result->getFile()->getPathname();
// $path = $result->getFile()->getPath();
// $fileName = $result->getFile()->getFilename();
// $testPath = public_path('images/fa9e99dce6a114bc77e929f9ed94a959.jpg');
$info = response()->download($absPath, 'info.xlsx');
}
$absPath 是绝对路径。
推荐文章: