jump to navigation

php code for delete directory and there files November 11, 2009

Posted by ashwinisingh in 1.
Tags:
add a comment

$full=$_SERVER[‘DOCUMENT_ROOT’].”/”.$dirdel;

function delete_directory($dirname) {
if (is_dir($dirname)){
$dir_handle = opendir($dirname);
}
if (!$dir_handle){
return false;
}
while($file = readdir($dir_handle)) {
if ($file != “.” && $file != “..”) {
if (!is_dir($dirname.”/”.$file))
unlink($dirname.”/”.$file);
else
delete_directory($dirname.’/’.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
if(delete_directory($full))
{
echo “done”;

}
else
{
echo “error”;
}

php code for resize image November 11, 2009

Posted by ashwinisingh in PHP.
Tags: ,
add a comment

Here $newname will be full path including image name

example https://ashwinisingh.wordpress.com/emages/test.jpg

list($width, $height) = getimagesize($newname) ;
$modwidth = 215;
$modheight=67;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($newname) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $newname,100) ;