Thursday, February 16, 2012

zip directory and sub-directory files using php

$s='template';

$zip = new ZipArchive();
if($zip->open('template/template.zip',false ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}

$this->recursive('template',$zip);

function recursive($s,$zip)
{
$dir = opendir($s);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($s . '/' . $file) ) {
recursive($s . '/' . $file,$zip);
}
else {
$d = end(explode('/',$s));

$zip->addFile($s . '/' . $file,$d.'/'.$file);
}
}
}
closedir($dir);
}

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...