i want to make zip and download just 1 folder but laravel adds every files in every folder in that directory to zip file and then download it
here is my code:
$license = license::findOrFail($id);
$path = public_path() . '/Qr/subs/' . $license->system_code;
$zip = new ZipArchive;
$fileName = 'photos.zip';
if ($zip->open(public_path($fileName), ZipArchive::CREATE) === TRUE) {
$files = File::files(public_path("/Qr/subs/{$license->system_code}/"));
foreach ($files as $key => $value) {
$relativeNameInZipFile = basename($value);
$zip->addFile($value, $relativeNameInZipFile);
}
$zip->close();
}
return response()->download(public_path($fileName));
and this is what my directory looks like:
problem is that i get my license from db and get all the files in folder(folder is named with license system_code) and add it to zip file and download it, but Laravel adds every file in every folder which are in Qr/subs to zip file and then download it
what i'm doing wrong???
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…