Laravel,使用https协议导出pdf时出错

问题描述

我有一种方法来收集一系列记录并将其发送到视图,然后导出为pdf,我使用Laravel和dompdf

 /**
 * @param Request $request
 * @param $id
 * @return mixed
 */
public static function pdfExport(Request $request,$id)
{

    $day = $request->get('day');

    ...
    $group_arr = [];


    $pdf = PDF::loadView('front.cars.pdfExport',compact('group_arr'));

    return $pdf->download('cars.pdf');

}

然后视图如下所示

<style>
    .table{width:100%;margin-bottom:1rem;color:#212529}
</style>

<table>
    <tr>
        <td bgcolor="#415981">
            <img id="deFinition-image" width="50%" height="50%" src="{{asset('assets/img/logo/logo.png')}}"><br>
        </td>
    </tr>
    <tr>
        <td>TEST PDF
        </td>
    </tr>
</table>

如果我通过http://进行呼叫,则此代码在我的本地计算机和服务器上都可以使用,而不是通过https://

进行。

我从chrome中收到一条错误消息,提示错误:网络错误

解决方法

download()需要文件路径。您可能应该只使用Storage :: download