I've created a simple programe that put photos into ZipArchive. All is working till I try to compress more than a couple photos (about 60). And after than I have something like that on a screen:
https://i.stack.imgur.com/DtgHG.png
I've changed max_execution_time to 1200 and memory_limit to 256M in php.ini.
Server is on Nginx 1.18 with PHP7.4 and Ubuntu 20.4. All is working on Laravel 8.
Any ideas?
This is my ZipController
public function downloadZip(Request $req){
$id = $req->input('id');
$sessions = DB::table('sessions')->where('id', $id)->get();
$photos = DB::table('sessions_files')->where('session_id', $id)->get();
$zip = new ZipArchive;
$path = 'images/sessions/'.$id;
$fileName = 'Sesja-numer-'.$id.'.zip';
if ($zip->open($fileName, ZipArchive::CREATE) === TRUE)
{
$numerek = 1;
foreach ($photos as $photo) {
echo $photo->file;
$addFile = $path.'/'.$photo->file;
$fileNewName = 'Zdjecie-'.$numerek.'.jpg';
$zip->addFile($addFile, $fileNewName);
$numerek++;
}
ob_end_clean();
$zip->close();
}
return response()->download($fileName)->deleteFileAfterSend();
return redirect('/dashboard/sessions/'.$id);
}