📜 ⬆️ ⬇️

Create an archive on the fly using the Create ZIP File class

image
Class Create ZIP File
Very interesting class that forms a full-fledged work with ZIP archives

Create a class object:
$createZip = new createZip;

Add the file to the archive:
$file = "FILE";
$createZip - >addFile($file, "file.data");

Let's test the script, upload any file to our server (in my case it is file.data), and package it in a zip archive and save it to disk.
//
$file = file_get_contents("file.data");
$createZip->addFile($file, "file.data");
$fileName = "file.zip";
$fd = fopen ($fileName, "wb");
$out = fwrite ($fd, $createZip -> getZippedfile());
fclose ($fd);
//
$createZip -> forceDownload($fileName);

')

Source: https://habr.com/ru/post/45015/


All Articles