Thursday, 30 April 2015

How to delete the Zend Cache files from server


How to delete the zend cache files from server


How to create an object of Zend Cache
$cache = Zend_Cache::factory(
                        'Core', 'File', array(
                    'lifetime' => 3600 * 24 * 7, //cache is cleaned once a day                            
                    'automatic_serialization' => true
                        ), array('cache_dir' => APPLICATION_PATH . '/cache')
        );


Remove the cache by cache-id In this only one cache file will be removed from server.
$cache->remove('idToRemove');


Remove All cache files from Server. (When we delete files, caching automatic clear because we are using cache in files)
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);


Remove all outdated caching files.
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);


Remove the cahe files which have two tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_TAG,
    array('matchingTag1', 'matchingTag2','matchingTag3') //Will remove which have matchingTag1 and matchingTag2 and matchingTag3
);


Remove all files which have not tag assign few tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
    array('NotmatchingTag1', 'NotmatchingTag2') //Will Remove all the cahce which are NOT tagged with NotmatchingTag1 OR NotmatchingTag2
);


Remove all the cache files which have any tag (any of two or three).
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, //Will remove which have matchingTag1 OR matchingTag2 OR matchingTag3
     array('matchingTag1', 'matchingTag2','matchingTag3')
);








Wednesday, 29 April 2015

Convert image to Binary Data and vice versa in PHP

 Convert image to Binary Data and vice versa in PHP

How to Convert image to Binary Data
$imageURL ='http://www.aboutcity.net/images/web-technology-experts-notes.jpg';
$contents = base64_encode(file_get_contents($imageURL));
/** Now stored the $contentes in Database or In Server**/


/** Now stored the $contentes in Database or In Server**/


How to display the Binary image data in Browser.
/** get the binary image data and stored in $contents variable **/
$contents='BINARY IMAGE DATA';
 echo "<img src="data:image/jpg;charset=utf8;base64,$contents" />";


How to get the image size (Height and Width) from binary data 
$file ='http://www.aboutcity.net/images/web-technology-experts-notes.jpg';
$contents = file_get_contents($file);
          
$image = imagecreatefromstring($contents);
echo 'Width: '.imagesx($image);
echo "\n";
echo 'Height: '.imagesy($image);