【问题标题】:Permission denied on storage/app/all_html/1658920379.blade.php. The communication protocol is not supportedstorage/app/all_html/1658920379.blade.php 的权限被拒绝。不支持通讯协议
【发布时间】:2022-08-02 19:25:47
【问题描述】:

嗨,我只想将我的存储文件下载为 pdf,但它显示此错误。 这是我的控制器

public function html(Request $request, $id=null){
    if($request->isMethod(\'post\')){
        $html = $request->html;
        $data = [];
        if($request->hasFile(\'html\')){
            // dd($html);
            $data[\'html\'] = $request->file(\'html\')->storeAs(\'all_html\', time().\'.blade.php\');
            // $data[\'html\'] = Storage::putFile(\'all_html\', $html);  
        }
        $url = \"storage/app/\".$data[\'html\'];
        $random = \'dOC\'.str::random(\'10\');
        Pdf::loadfile($url)->setPaper(\'a4\', \'landscape\')->setWarnings(false)->save(public_path(\'pdf/\'.$random.\'.pdf\'));
        return response()->download(public_path(\'pdf/\'.$random.\'.pdf\'));
    }
    return view(\'html\');
}

    标签: laravel permissions storage laravel-7 dompdf


    【解决方案1】:

    如果存储未链接,您需要先检查 laravel 存储链接,然后您需要在终端中运行以下命令

    存储链接命令 => php artisan storage:link

    然后检查我们的代码并再次运行

    编码快乐!!

    【讨论】:

      猜你喜欢
      • 2018-01-15
      • 2021-04-12
      • 1970-01-01
      • 2014-06-27
      • 1970-01-01
      • 2021-08-10
      • 2018-11-24
      • 1970-01-01
      • 2023-03-18
      相关资源
      最近更新 更多