PhpConcept

Developers Tools

  • Increase font size
  • Default font size
  • Decrease font size
Home PclZip User Guide

PclZip User Guide - PCLZIP_OPT_EXTRACT_DIR_RESTRICTION

Print PDF

PCLZIP_OPT_EXTRACT_DIR_RESTRICTION

PclZip can extract any file in any folder of a system. People may use this to upload a zip file and try to override a system file or any other file (password file, ...). The PCLZIP_OPT_EXTRACT_DIR_RESTRICTION gives the ability to forgive any directory transversal behavior.
The use of this option can also be convenient to limit simple errors in some scripts.

Be aware that a better security is to use the directory restriction of PHP configuration.

The following example will reject the extraction of any file in the archive that are not in the "/var/www/data" folder.

    $archive = new PclZip('test.zip');
    
$list $archive->extract(PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"/var/www/data");
    if (
$list == 0) {
      echo 
"ERROR : ".$archive->errorInfo(true);
    }
 

 

[Optional Arguments List]

 

Last Updated on Friday, 18 December 2009 13:27