This blog uses responsible cookies for functionality and user preferences.
Google Analytics is used for collecting general public information to understand how my blog is used.
Learn moreScript Title: zipAPI
Programming Language: PHP5
Date Completed: 2016-02-07
Purpose: Easily create and extract ZIP archives.
Description: PHP class for creating and extracting ZIP archives. Provides easy to use functions and powerful features.
Method:
set_defaults();
Function to reset all options to their defaults.
set_overwrite( BOOLEAN );
Option to overwrite an existing zip file if it already exists. Default value false.
set_include_dirname( BOOLEAN );
Option to include the parent folder name when creating a zip file. Default value true. If set to false, only the contents of the selected folder will be archived.
exclude_extension( STRING );
Function to add a file extension to be excluded while creating an archive.
Note: also allows wild cards * ?.exclude_file( STRING );
Function to add a file (full path) or file name to be excluded while creating an archive.
Note: also allows wild cards * ?.exclude_folder( STRING );
Function to add a folder (full path) or folder name to be excluded while creating an archive.
Note: also allows wild cards * ?.clear_exclude_extensions();
Function to remove all extensions from the exclusion list.
clear_exclude_files();
Function to remove all files from the exclusion list.
clear_exclude_folders();
Function to remove all folders from the exclusion list.
error_console();
Function to return an array of error messages. Returns an array.
fileExists( ZIPFILE = “”, FIND = “”, [case insensitive = false] );
Function to determine if a file or directory exists in an archive. Returns true or false. Will return false if an error has occurred.
numFiles( ZIPFILE = “” );
Function to count the number of entries in the archive. Entries include files and folders. Returns a number. Will return false if an error has occurred.
scanArchive( ZIPFILE = “”, [MODE = 0/1] );
Function to list all files and directories in an archive. Returns an array.
Mode 0 (default): Returns only the files and directories.
Mode 1: Returns all archive details.
Will return false if an error has occurred.extractTo( ZIPFILE = “”, DESTINATION_PATH = “” );
Function to extract a zip file to a given path. Returns true or false. Will return false if an error has occurred.
createTo( TARGET_PATH = “”, DESTINATION_PATH = “” );
Function to create a zip file from a given path. Returns true or false. Will return false if an error has occurred.
Example Usage:
$nuZip = new zipAPI();
if ( !$nuZip->createTo(“../FileMan2”, “../newarchive.zip”) ) {
echo “Errors:”;
print_r ( $nuZip->error_console() );} else {
echo “Complete”;
if ( !empty($nuZip->error_console()) ) {
echo “Errors:”;
print_r ( $nuZip->error_console() );}
}
Terms of Use, Cookies, Privacy, and more, see Terms and Privacy
Third-party copyrights and trademarks featured on this site are owned by their respected holders.
Website written and designed by Patcoola 2019, some rights reserved.
This blog uses responsible cookies for functionality and user preferences.
Google Analytics is used for collecting general public information to understand how my blog is used.
Learn moreDear EU visitor, I am required to ask you consent for the following.