Blog

22 de June de 2023

Compress files with PHP

Compactar arquivos com PHP

To be able to compress the files, we will use the class ZipArchive which is a native class of PHP itself.

		// Create a variable to be the zip
$zip = new ZipArchive();

// Create your zip file
$zip->open(\'FileName.zip\', ZIPARCHIVE::CREATE);

// Add files inside the ZIP
$zip->addFile( \'text.txt\' , \'text.txt\' );
// Remembering that this step can be done as many times as necessary.
// Inside the parentheses, the first is where the file is and the second is the name it will be inside the ZIP.

// Closing the ZIP file
$zip->close();
// It is very important that we close the file at the end
Share:
Others

Tips

Efeito Typewrite

Typewrite effect

View more

Forçar o HTTPS

Force HTTPS

View more

ShortCode

ShortCode

View more