Laravel filesize():统计失败

时间:2019-07-07 08:20:45

标签: php laravel

我具有下载某些文件的功能。它可以在localhost上运行,但是,当我将其上传到GoDaddy上时,出现异常。

  

ErrorException(E_WARNING)filesize():stat失败

$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 个答案:

没有答案