Skip to main content

Posts

Showing posts from August, 2010

PHP:function to extract files from zip

The  unzip.php   program, shown in  Example, extracts files from a ZIP archive. It uses the  pc_mkdir_parents( )  function. The program also requires PHP's  zip   extension to be installed. You can find documentation on the  zip  extension at  http://www.php.net/zip . This program takes a few arguments on the command line. The first is the name of the ZIP archive it should unzip. By default, it unzips all files in the archive. If additional command-line arguments are supplied, it only unzips files whose name matches any of those arguments. The full path of the file inside the ZIP archive must be given. If  turtles.html  is in the ZIP archive inside the  animals  directory,  unzip.php  must be passed  animals/turtles.html , not just turtles.html , to unzip the file. Directories are stored as 0-byte files inside ZIP archives, so  unzip.php  doesn't try to create them. Instead, before it creates any other file, it uses  pc_mkdir_parents( )  to create all directories that are par...