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

    Class Create ZIP File
    A very interesting class that forms a full-fledged work with ZIP archives.

    Create a class object: Add a file to the archive: Let's test the script, upload any file to our server (in my case it is, and pack it into a zip archive and save to disk.
    $createZip = new createZip;

    $file = "FILE";
    $createZip - >addFile($file, "");

    // Получим содержимое файла в виде одной строки
    $file = file_get_contents("");
    $createZip->addFile($file, "");
    $fileName = "";
    $fd = fopen ($fileName, "wb");
    $out = fwrite ($fd, $createZip -> getZippedfile());
    fclose ($fd);
    // Линк на наш архив
    $createZip -> forceDownload($fileName);

    Also popular now: