Thursday, February 16, 2012
zip directory and sub-directory files using php
$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);
}
Wednesday, February 15, 2012
Iframe image upload using jquery
<script type='text/javascript'>
$(document).ready(function(){
$('#banner').submit(function(){
$('#imgbanner').attr('src','loading.gif');
});
$('iframe[name=upload_banner]').load(function(){
var result = $(this).contents().text();
if(result !=''){
$('#imgbanner').attr('src',$(this).contents().text());
}
});
});
function gob()
{
$('#bannerdiv').hide();
document.frmb.submit();
}
$(document).ready(function(){
$("#bbtn").click(function(){
$("#banner").click();
});
});
</script>
<style>
div#bannerdiv iframe {
position:fixed;
left:-9000px;
width:1px;
height:1px;
}
div#bannerdiv img {
max-width:150px;
max-height:150px;
}
</style>
<div class="banner">
<div id='bannerdiv' style="padding-left:200px; width:100px;">
<form id='bannerfrm' name="frmb" method='post' enctype='multipart/form-data' action='bannerupload.php' target='upload_banner'>
<p><input type='file' id='banner' name='banner' onchange="gob()" style="display:none;"/> </p>
</form>
<div id="bbtn" name="bbtn" style="background-color:#999999; border:2px double #666666; width:310px; height:100px;">Upload Banner</div>
</div>
<span style="padding-left:220px; padding-bottom:40px;"><img id="imgbanner" /></span>
<iframe name='upload_banner' style="display:none;">
</iframe>
</div>
In bannerupload.php
<?php
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...
-
Find highcharts which are loaded in the page and then convert chart into png using jquery Charts are loaded through the ajax See the e...