dongye4192 2019-07-07 08:20
浏览 201

Laravel filesize():stat失败

I have a function to download some files. It works on localhost however, after I upload it on GoDaddy I get an exception.

ErrorException (E_WARNING) filesize(): stat failed for

$zip->open($zip_name, ZipArchive::CREATE);
if ($number_of_files >= 1) {
    if ($param === 'documents') {
        foreach ($file as $files) {
            for ($i = 1; $i <= 6; $i++) {
                $path = public_path()."/documents/".$files->$i;
                if (file_exists($path)) {
                    $zip->addFromString($files->$i, file_get_contents($path));
                }
            }
        }
    } else {
        foreach ($file as $files) {
            $path = public_path().'/safetySystemsSchema/'.$files->title;
            if (file_exists($path)) {
                $zip->addFromString($files->title, file_get_contents($path));
            }
        }
    }
    $zip->close();
    $headers = [
        'Content-Type: application/zip',
        'Content-disposition: attachment; filename='.$zip_name,
        'Content-Length: '.filesize($zip_name)
    ];
    response()->download($zip_name, $zip_name, $headers);

    return Response::download($zip_name)->deleteFileAfterSend(true);
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?