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...
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...
Please check out this url:
http://mig.sourceforge.net/gallery/index.php?currDir=.
And i want to implement my galley in this way..
Please post me any information.
Please help me....
Once Check my thread and reply..
please.....
i have done this before for someone on daniweb. search through old threads and you should find something that can help you.
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...
Hi Shanti,
It was a nice idea, so I worked on it and came with this. This will help you.
<style>
td{font: 12px Arial; color: #333333;}
</style>
<script language=javascript>
function clicked(val)
{
location.href = "rec_dir_list.php?dir="+val;
}
</script>
<html>
<title>Foto Album</title>
<body>
<?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 '<center><table><tr>';
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 '</tr><tr>';
}
echo '<td><table border=1><tr><td><img src="'.$imgdir.'/'.$a_img[$x].'" width='.$halfwidth.' height='.$halfheight.'></td></tr></table></td>';
if($level==1)
{
break;
}
}
if($totimg%4 == 0)
{
echo '</table>';
}
else
{
echo '</tr></table>';
}
}
else
{
echo '<center><table><tr><td>No Images found</td></tr></table>';
}
}
function recur_dir($dir)
{
$flag=0;$ind=1;
$dirlist = opendir($dir);
echo '<center><table bgcolor=#eeeeee width="30%"><tr>';
while ($file = readdir ($dirlist))
{
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (is_dir($newpath))
{
$ind += 1;
$flag = 1;
echo "<td>";
echo '<center><table><tr><td>';
list_images($dir.'/'.end($level),1);
echo '</td></tr><tr><td align=center>';
echo '<a href=javascript:clicked("'.$dir.'/'.end($level).'")>'.end($level).'</a>';
echo '</td></tr></table>';
echo "</td>";
}
}
}
if($flag==0)
{
echo "<td>";
list_images($dir,0);
echo "</td></tr><tr><td><hr>Current Dir: ". $dir;
echo "</td></tr></table>";
}
else
{
echo "</tr><tr><td colspan=".$ind." align=center><hr>Current Dir: ". $dir;
echo "</td></tr></table>";
}
closedir($dirlist);
}
$curr_dir = $_REQUEST['dir'];
if($curr_dir == "")
{
$curr_dir = './images';
}
recur_dir($curr_dir);
?>
</body>
</html>
Thanks vivek...
I will have a look..
hi vivek,
i tried ur code and i am getting error
Notice: Undefined index: dir in D:\www\arya\images.php on line 113
in this line $curr_dir = $_REQUEST;
could u help me
thanks in advance
vicky's code is fantastic
just comment out line 22 and create a directory 'images' after that store some images in it
thanks for reply nil,i have done that but still iam getting error
thanks in advance
its just a notice not an error. the script should still work. just change your error reporting to not show notices.
i got this error:
Notice: Undefined index: dir in imggallery.php on line 112
$curr_dir = $_REQUEST;
Hi Friends,
Good news, I have modified the script somewhat more.now it supports
1. moving in directory ans subdirectories.
2. moving up the directory
3. slide show of the images.
just edit the following code and replace the "images" with the directory you want your photo album to start with.
if($curr_dir == "")
{
$curr_dir = 'images';
}
Cheers.
<?
$totimg = 0;
$img_ind = $_REQUEST['img_ind'];
$imgdir = $_REQUEST['img_dir'];
$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 +=1;
}
}
$size = getimagesize($imgdir.'/'.$a_img[$img_ind]);
$imgpath = $imgdir.'/'.$a_img[$img_ind];
if($img_ind > 0)
$prev_ind=$img_ind-1;
else
$prev_ind=$img_ind;
if($img_ind < $totimg-1)
$next_ind=$img_ind+1;
else
$next_ind=$img_ind;
?>
<center>
<table width=100%>
<tr>
<td align=center>
<table width="461">
<tr><td width="142">
<p align="right"><a href="disp_image.php?img_dir=<?=$imgdir?>&img_ind=<?=$prev_ind?>">Previous</a></td><td width="11">||</td><td width="116"><a href="disp_image.php?img_dir=<?=$imgdir?>&img_ind=<?=$next_ind?>">Next</a></td>
<td width="164"><a href="photoalbum.php?dir=<?=$imgdir?>">Go to Thumbnail View</a></td></tr>
</table>
</td></tr>
<tr><td align=center>
<table><tr><td style="padding-top:15px"><img src=<?=$imgpath?>></td></tr>
</table>
</td></tr></table>
</center>
<style>
td{font: 12px Arial; color: #333333;}
</style>
<script language=javascript>
function clicked(val)
{
location.href = "photoalbum.php?dir="+val;
}
function displayimg(val,x)
{
location.href = "disp_image.php?img_dir="+val+"&img_ind="+x;
}
</script>
<html>
<title>Foto Album</title>
<body>
<?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);
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 '<center><table><tr>';
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 '</tr><tr>';
}
if($level==1)
{
echo '<td><table border=1><tr><td><a href=javascript:clicked("'.$imgdir.'")><img src="'.$imgdir.'/'.$a_img[$x].'" width='.$halfwidth.' height='.$halfheight.'></a></td></tr></table></td>';
}
else
{
echo '<td><table border=1><tr><td><a href=javascript:displayimg("'.$imgdir.'",'.$x.')><img src="'.$imgdir.'/'.$a_img[$x].'" width='.$halfwidth.' height='.$halfheight.'></a></td></tr></table></td>';
}
if($level==1)
{
break;
}
}
if($totimg%4 == 0)
{
echo '</table>';
}
else
{
echo '</tr></table>';
}
}
else
{
echo '<center><table><tr><td>No Images found</td></tr></table>';
}
}
function recur_dir($dir)
{
$flag=0;$ind=1;
$dirlist = opendir($dir);
echo '<center><table bgcolor=#eeeeee width="30%"><tr>';
while ($file = readdir ($dirlist))
{
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (is_dir($newpath))
{
$ind += 1;
$flag = 1;
echo "<td>";
echo '<center><table><tr><td>';
list_images($dir.'/'.end($level),1);
echo '</td></tr><tr><td align=center>';
echo '<a href=javascript:clicked("'.$dir.'/'.end($level).'")>'.end($level).'</a>';
echo '</td></tr></table>';
echo "</td>";
}
}
}
$arrlevel = explode('/',$dir);
$upbyonelevel="";
if(count($arrlevel) > 1)
{
for($i=0;$i < count($arrlevel)-1;$i++)
{
if($i==0)
{
$upbyonelevel = $upbyonelevel. $arrlevel[$i];
}
else
{
$upbyonelevel = $upbyonelevel."/". $arrlevel[$i];
}
}
}
else
{
$upbyonelevel = $dir;
}
if($flag==0)
{
echo "<td>";
list_images($dir,0);
echo "</td></tr><tr><td align=center><br><br><br><br><a href=javascript:clicked('".$upbyonelevel."')>Go Up by 1 level</a><hr><b>Current Dir:</b> ". $dir;
echo "</td></tr></table>";
}
else
{
echo "</tr><tr><td align=center colspan=".$ind." align=center><br><br><br><br><a href=javascript:clicked('".$upbyonelevel."')>Go Up by 1 level</a><hr><b>Current Dir: ". $dir;
echo "</td></tr></table>";
}
closedir($dirlist);
}
$curr_dir = $_REQUEST['dir'];
if($curr_dir == "")
{
$curr_dir = 'images';
}
recur_dir($curr_dir);
?>
</body>
</html>
okk friends use this code this is just modified and runnig fantastically.......
<style>
td{font: 12px Arial; color: #333333;}
</style>
<script language=javascript>
function clicked(val)
{
location.href = "rec_dir_list.php?dir="+val;
}
</script>
<html>
<title>Foto Album</title>
<body>
<?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 '<center><table><tr>';
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 '</tr><tr>';
}
echo '<td><table border=1><tr><td><img src="'.$imgdir.'/'.$a_img[$x].'" width='.$halfwidth.' height='.$halfheight.'></td></tr></table></td>';
if($level==1)
{
break;
}
}
if($totimg%4 == 0)
{
echo '</table>';
}
else
{
echo '</tr></table>';
}
}
else
{
echo '<center><table><tr><td>No Images found</td></tr></table>';
}
}
function recur_dir($dir)
{
$flag=0;$ind=1;
$dirlist = opendir($dir);
echo '<center><table bgcolor=#eeeeee width="30%"><tr>';
while ($file = readdir ($dirlist))
{
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (is_dir($newpath))
{
$ind += 1;
$flag = 1;
echo "<td>";
echo '<center><table><tr><td>';
list_images($dir.'/'.end($level),1);
echo '</td></tr><tr><td align=center>';
echo '<a href=javascript<b></b>:clicked("'.$dir.'/'.end($level).'")>'.end($level).'</a>';
echo '</td></tr></table>';
echo "</td>";
}
}
}
if($flag==0)
{
echo "<td>";
list_images($dir,0);
echo "</td></tr><tr><td><hr>Current Dir: ". $dir;
echo "</td></tr></table>";
}
else
{
echo "</tr><tr><td colspan=".$ind." align=center><hr>Current Dir: ". $dir;
echo "</td></tr></table>";
}
closedir($dirlist);
}
$curr_dir = $_REQUEST['dir'];
if($curr_dir == "")
{
$curr_dir = './images';
}
recur_dir($curr_dir);
?>
</body>
</html>
but you people must create a folder 'images' exactly where you keep this page with some images..
Hi Nil,
Can you please let me know, what modificatio you have made.
I think you uncommented the following line
$imgdir = 'images/'; // the directory, where your images are stored
if yes, then this will make this code to work in only one level.
I have made this script to work in more then one levels.
hi vicky sorry for trouble,
i have a images in 'images folder' and images2
as sub folder when i click on sub folder iam getting images in actual 'imagesfolder'
thanks again
Hi Shanti,
I have included the files that matches exactly your requirements in my earlier posts.
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
Notice: Undefined variable: a_img in E:\web\test\photoalbum.php on line 39
Either turn off notices or initialize your variables before using them. This way, one can avoid notices.
The problem is I am not getting any error, its running smooth on my system.
Which OS u r using?
The problem is I am not getting any error, its running smooth on my system.
Which OS u r using?
Its not OS dependent. Go to php.ini and search for ; Error handling and logging ;, and use this.
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT This will show all errors except notices.
Hi Nav,
Sorry, I am not in PHP, I work in ASP.
These days I am learning PHP, so I don't know much about php.ini file.
Thank you so much Vivek Rawat for your help....
Hi Nav,
Sorry, I am not in PHP, I work in ASP.
These days I am learning PHP, so I don't know much about php.ini file.
Ah! I see.. Btw, Good work with your script :)
it is working well, BUT the problem is that if I have for example four pictures in images, in thumbnail I see all those four, but i click on one of them and goes to disp_image.php, then I see just the second and the fourth, it means I can not see the first, but see the second, not the third, but the i see the fourth and so on ...
what can be the problem?
Hi,
i think I got your problem :)
Please check, what are the file extensions in your image directory.
As in this script only these extensions are allowed 'png','jpg','jpeg','gif'
If you want to add more extensions.
just change the line in both the files, add the new extensions that you wish.
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
k thank you...
NO. mine is all jpg images. I can see all of them in thumbnail page, but in disp-image I can not see every other one
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.