尝试下载zip文件时出现此错误
{
"globalDependencies": {
"dotenv": "registry:dt/dotenv#2.0.0+20160327131627",
"express": "registry:dt/express#4.0.0+20160708185218",
"express-serve-static-core": "registry:dt/express-serve-static-core#4.0.0+20160805091045",
"mime": "registry:dt/mime#0.0.0+20160316155526",
"mongodb": "registry:dt/mongodb#2.1.0+20160602142941",
"mongoose": "registry:dt/mongoose#4.5.4+20160807120805",
"mongoose-promise": "registry:dt/mongoose-promise#4.5.4+20160720003345",
"node": "registry:dt/node#6.0.0+20160807145350",
"promise": "registry:dt/promise#7.1.1+20160602154553",
"serve-static": "registry:dt/serve-static#0.0.0+20160606155157"
}
}
我的代码
The file "C:\wamp\www\Petro\public\download/downloads.zip" does not exist
创建了zip但我无法下载,我的代码出了什么问题?
我在创建zip后使用if (\File::exists('download/downloads.zip')) {
$directory = public_path('download');
$success = \File::cleanDirectory($directory);
foreach($checked as $check){
$path = File::where('name',$check)->select('real_path')->first();
$img = \Image::make($path->real_path);
$img->save(public_path('download'). '/'. $check);
}
} else {
foreach($checked as $check){
$path = File::where('name',$check)->select('real_path')->first();
$img = \Image::make($path->real_path);
$img->save(public_path('download'). '/'. $check);
}
}
$files = \File::files('download');
\Zipper::make('download/downloads.zip')->add($files);
$pathtoFile = public_path('download/downloads.zip');
return response()->download($pathtoFile);
:
dd($files)
没有zip文件但如果我在我的本地目录中检查了zip是否已创建。 你能帮我个忙吗,对不好的英语感到抱歉。
答案 0 :(得分:0)
正如您在错误中看到的那样,您有/
而不是\
这个。
The file "C:\wamp\www\Petro\public\download/downloads.zip" does not exist
^
Here
将以下行中的/
更改为\
:
$pathtoFile = public_path('download/downloads.zip');
要
$pathtoFile = public_path('download\downloads.zip');
答案 1 :(得分:0)
您需要关闭此过程。
Zipper::make('download/downloads.zip')->add($files)->close();