Urgent requirement of image gallery in php
hello...
Can any one please help me out?
I want an image gallery script, where the images are displayed as thumbnails from many subfolders created dynamically and not from database...
Thanks in Advance...
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Once Check my thread and reply..
please.....
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
i have done this before for someone on daniweb. search through old threads and you should find something that can help you.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
Hello keith...
Thanks for your reply...
I have reffered all your old posts...
But i found nothing according to my requirement...
I think you have enough knowledge to clear my thread...
Please help...
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Thanks vivek...
I will have a look..
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
vicky's code is fantastic
just comment out line 22 and create a directory 'images' after that store some images in it
nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
its just a notice not an error. the script should still work. just change your error reporting to not show notices.
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
<?php
//level variable will hold 1 or 0, depending on if the directory has only files.
//1 - if sub-folders are still there
//0 - if only image files are there.
function list_images($imgdir,$level)
{
$imgdir = 'images/'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
$dimg = opendir($imgdir);
$imgfile = readdir($dimg);
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
if($totimg > 0)
{
echo '';
for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);
$halfwidth = ceil($size[0]/4);
$halfheight = ceil($size[1]/4);
if($x % 4 == 0 && $x != 0)
{
echo '';
}
echo '
';
if($level==1)
{
break;
}
}
if($totimg%4 == 0)
{
echo '';
}
else
{
echo '';
}
}
else
{
echo 'No Images found';
}
}
function recur_dir($dir)
{
$flag=0;$ind=1;
$dirlist = opendir($dir);
echo '';
while ($file = readdir ($dirlist))
{
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (is_dir($newpath))
{
$ind += 1;
$flag = 1;
echo "";
echo '';
list_images($dir.'/'.end($level),1);
echo '';
echo ':clicked("'.$dir.'/'.end($level).'")>'.end($level).'';
echo '';
echo "";
}
}
}
if($flag==0)
{
echo "";
list_images($dir,0);
echo "Current Dir: ". $dir;
echo "";
}
else
{
echo "Current Dir: ". $dir;
echo "";
}
closedir($dirlist);
}
$curr_dir = $_REQUEST['dir'];
if($curr_dir == "")
{
$curr_dir = './images';
}
recur_dir($curr_dir);
?>
nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
Hi Shanti,
I have included the files that matches exactly your requirements in my earlier posts.
Its gud..
Very thanks for your time...
But i got this error..
Notice: Undefined variable: a_img in E:\web\test\photoalbum.php on line 39
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162