php - Laravel filesize(): stat failed
问题描述
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);
}
解决方案
推荐阅读
- c# - SSRS - 以编程方式更新数据源凭据中的密码
- spring-boot - 如何在子类 JPA 中覆盖超类的映射列的类型
- python-3.x - 我的网页抓取工具一直有效,直到我将它与 for 循环一起使用
- javascript - 使用 Array 方法`.reduce()`,请编写循环遍历对象数组并返回分析的逻辑
- php - 生产中的 Laravel - Docker
- wordpress - 如何使用 LearnDash 插件创建课程播放列表?
- fp-ts - fp-ts:如何展平 ReaderTaskEither 数组的一层?
- excel - 除法公式相加
- verilog - RTL if 语句与模拟不匹配
- ios - 如何生成逐渐改变颜色的调色板