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);
}
douliang1900
douliang1900 是的,它存在和文件夹权限775
一年多之前 回复
dongluo6343
dongluo6343 你的文件甚至存在吗?这看起来像$zip_name中的路径不存在或不可访问。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐