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

Há quanto tempo foi atualizado?

How long has it been updated?

View more

Texto com Degradê

Gradient text

View more

Erro ao subir o projeto React

Erro ao subir o projeto React

View more