Compressing files with PHP 5.1.6

Asked

Viewed 147 times

2

I need to Compress files using PHP but my version is 5.1.6, I only tried to create the folder .zip using the code below, however, as stated in the manual this functionality is only available from version 5.2.

<?php

$MD = date('md');
$dado = "Ticker_70_".$MD."_IPCDA.sql";

$Zipar = new ZipArchive();

$Zipar->open($dado.'.zip', ZIPARCHIVE::CREATE);

?>

I wonder if there is another method to compress files with PHP that works for my current version, through libraries outside or native of this version.

Edit1: I’m using Linux.

2 answers

5


To use ZIP in PHP 5.1 you must install the pecl extension ZIP

The code is right, just install the extension. Since php is kind of old, you will have to compile the extension on your own.

You can choose to use the library Pclzip

2

if you are in the best way linux with this php version is using the shell_exec

$dado = "Ticker_70_".$MD."_IPCDA.sql";
shell_exec("zip ".$dado.".zip $dado");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.