I create a zip file using ZipArchive, where I record images. The process is quite long, but VPS allows.
$zip = new ZipArchive(); $imagesZipFile = __DIR__.'/../files/images_' . $xmlCreateDatetime . '.zip'; $imageNewName = 'autocity_'.$car['id']; $i = 0; foreach($imagesArray as $image){ if($image != '..' AND $image != '.'): // Add image to zip if($zip->open($imagesZipFile, ZipArchive::CREATE)!==TRUE): continue; endif; $zip->addFile($imageDir . '/' . $image, $imageNewName.$image); // Add string to xml $ImageElt = $domDoc->createElement('Image'); $ImageName = $domDoc->createAttribute('name'); $ImageName->appendChild($domDoc->createTextNode($imageNewName.$image)); $ImageElt->appendChild($ImageName); $ImagesNode->appendChild($ImageElt); $i++; endif; } $zip->close(); As a result, the file is completely created, placed in the right folder, but at the end the script gives Gateway Timeout, although with small cycles it returns the desired variable.
As a result, two questions:
- Is it possible to somehow facilitate the process of creating an archive (maybe memory clearing or something like that)
- Is it possible to avoid the 504th error and, if so, how?