For a project in PHP, it was necessary to upload data to zip. The data are dynamic and are fairly weighty files. In total, the archive can take up to 800mb.

At the moment, generation is implemented through the ZipAchive class.

...какой-то код до $archive = 'filestorage/temp/'.$fileName; $zip = new ZipArchive(); $zip->open($archive, ZipArchive::CREATE); $files = FilesBank::getFilesInfo($photoIds); foreach($files as &$file) { $zip->addFile($file['phusicalPath'], $file['name']); } $zip->close(); header('Content-Type: application/zip'); header('Content-Length: ' . filesize($archive)); header('Content-Disposition: attachment; filename="'.$fileName.'"'); readfile($archive); unlink($archive); 

I use an intermediate temp file, as a result, a monstrous delay before downloading in 20-40 seconds.

How can you implement instant file delivery without first creating a tempo file?

  • one
    stackoverflow.com/a/17244786/1216425 ? or libraries from neighboring answers - teran
  • The option is interesting, but I would like to do with regular means. - Alexander Sutyrkin
  • Well this is how much data will take php-memory ... - MAX
  • No need to keep everything in memory, you need to use something like streams (as in the Java OutputStream). Those. read as data is downloaded to the user. Is there really nothing like that in php? - Alexander Sutyrkin
  • Specified in the first comment for php7, I use php 5.6. - Alexander Sutyrkin September

0