Image handling| list image folder – PHP


Image handling| list image folder – PHP

<?php

$imgdir = ‘/public_html/logs/’; // the directory, where your images are stored

$allowed_types = array(‘png’,’jpg’,’jpeg’,’gif’); // list of filetypes you want to show

$dimg = opendir($imgdir);

while($imgfile = readdir($dimg))

{

if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))

{

$a_img[] = $imgfile;

sort($a_img);

reset ($a_img);

}

}

$totimg = count($a_img); // total image number

for($x=0; $x < $totimg; $x++)

{

$size = getimagesize($imgdir.’/’.$a_img[$x]);

// do whatever

$halfwidth = ceil($size[0]/2);

$halfheight = ceil($size[1]/2);

echo ‘name: ‘.$a_img[$x].’ width: ‘.$size[0].’ height: ‘.$size[1].'<br />’;

}

?>

Advertisements

thanks 4 u comments..

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s