Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Best way to create large archives using PHP

Hi,

We're developing a simple system to tar.gz or zip large media files (10 to 200mb each) into 1GB segments with a set of files. From basic research we found zip (http://pecl.php.net/package/zip) is one option as exec command is disabled on our server. Although our server is not equipped with zip pecl extension, we can request our hosting company to install it. Is this the best way? Or can you expert guys suggest better alternatives?

Thanks in advance.
0
harvest-soft
Asked:
harvest-soft
2 Solutions
 
Chris HarteThaumaturgeCommented:
Php has several pre-compiled archiving utilities.

http://uk.php.net/manual/en/refs.compression.php



The zlib library is for use with gzip (.gz) files

http://uk.php.net/manual/en/book.zlib.php
0
 
eNarcCommented:
This will Allow you to zip a folder to the folders name while adding a log, when u get exec working.

<?php
      exec("zip -vr foldername zipname >> log.txt");
      echo "complete";
?>
0
 
harvest-softAuthor Commented:
For now, exec is ruled out for security reasons. Will have to decide between zip pecl extension and other better options if any.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
harvest-softAuthor Commented:
MunterMan,

http://uk.php.net/manual/en/zip.requirements.php isn't this same as zip pecl?
0
 
Chris HarteThaumaturgeCommented:
The zlib link I posted should work without having to install anything from pecl or making any changes to php.ini.
0
 
harvest-softAuthor Commented:
I am not sure how zlib could help zip multiple files.
0
 
Slick812Commented:
greetings harvest-soft, , The different "archives" packages available for PHP can be mis-understood, or confusing.
The PHP  Zlib and Bzip2 packages do compression on a Single data segment (string, or file) - - so you will need to combine many different files into a single file or string to use these, there are some classes available (PHP TAR classes) to do file combining, but it's an extra hassle.
The PHP Zip package would be better suited to your needs, since It can do many files and-or folders in a single Zip file, without addon packages or methods.

the PECL packages, are use to install methods and functions after the PHP is up and operating, It seems that the PECL Zip package, installs the PHP Zip (http://us2.php.net/manual/en/book.zip.php), if the PHP Zip is not already installed, , I believe that the default PHP installation and setup auto installs the Zip package, you can run the PHP  phpinfo ( );  function to see what packages you have on your server   OR  - just run this code line below -

$zip = new ZipArchive();

if you do not get an error message about "Class Not Found" then you have the PHP Zip ready to use, and you can get PHP code to use from the manual at -
http://uk.php.net/manual/en/zip.examples.php

I hope this gives you some information that helps, ask questions, if you need better explanation
0
 
harvest-softAuthor Commented:
Slick,

I've already checked the phpinfo and I know Zip wasn't installed. It's PHP 5.2.1
I basically wanted expert advice on what the most "production" suitable way to zip large media files. zlib is not going to help and I knew it. Anyways thanks guys.

0
 
harvest-softAuthor Commented:
Overall good. But needed expert voice.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now