Laravel 5 如何将Spatial/browsershot生成的文件下载到用户/下载中?

Laravel 5 如何将Spatial/browsershot生成的文件下载到用户/下载中?,laravel-5,download,Laravel 5,Download,在我使用的laravel 5.8应用程序中 如果我将文件另存为 $save_to_file= 'file.pdf'; Browsershot::html(htmlspecialchars_decode($pdf_content)) ->showBackground() ->save($save_to_file); 它被下载并保存在我本地操作系统上我的应用程序的/public dir中 如果我尝试将Kubuntu 18的“下

在我使用的laravel 5.8应用程序中

如果我将文件另存为

$save_to_file= 'file.pdf';
Browsershot::html(htmlspecialchars_decode($pdf_content))
               ->showBackground()
               ->save($save_to_file);
它被下载并保存在我本地操作系统上我的应用程序的/public dir中

如果我尝试将Kubuntu 18的“下载”目录的路径设置为

$save_to_file= '/home/currentuser/Downloads/file.pdf';
Browsershot::html(htmlspecialchars_decode($pdf_content))
               ->showBackground()
               ->save($save_to_file);
我得到一个错误:

Symfony \ Component \ Process \ Exception \ ProcessFailedException
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/mnt/_work_sdb8/wwwroot/lar/votes/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/0906513001561868598\/index.html","action":"pdf","options":{"path":"\/home\/serge\/Downloads\/file.pdf","args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /mnt/_work_sdb8/wwwroot/lar/votes/public Output: ================ Error Output: ==============
1) 是否有办法将生成的文件下载到“下载”(独立操作系统)中


2) 我想我可以使用php删除功能,但再次说明如何定义“下载”(操作系统独立)目录?

我收到了完全相同的错误。不知道我为什么会这样。遵循文档中提到的所有步骤。我试过各种各样的方法,但还是弄不明白

这终于奏效了
$save_to_file='/var/www/laravel/storage/app/file.pdf';
浏览器快照::url('https://www.google.com')
->noSandbox()->格式化('a4')->保存($save_to_file);

->noSandbox()
是关键。让我知道这是否对您有效。

我询问了pn Spatiale论坛,得到的答案是:>>>这与此软件包无关。保存仅将文件保存到指定的路径。您负责指定的路径。你能给我一些建议吗?