Thread: PHP Help
View Single Post
Old
  (#13)
BrianG
RC-Monster Admin
 
BrianG's Avatar
 
Offline
Posts: 14,609
Join Date: Nov 2005
Location: Des Moines, IA
02.28.2010, 12:34 AM

At the top of the page:

Code:
<?php

$imgdir = '.';

$allowed_types = array('png','jpg','gif');

$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

?>
and then, where the image listing is to be shown:

Code:
<?php

for($x=0; $x<$totimg; $x++){
	$t="";
	$size = getimagesize($imgdir.'/'.$a_img[$x]);
	$t=$t.+"\t".'<tr valign="top" align="left">'."\n\r";
	$t=$t.+"\t\t".'<td width="35"><b>'.($x+1).'.</b></td>'."\n\r";
	$t=$t.+"\t\t".'<td><a href="javascript:void(0)" onmouseover="showPic(this,\''.$imgdir.'/'.$a_img[$x].'\','.$size[0].','.$size[1].')">'.$a_img[$x].'</a></td>'."\n\r";;
	$t=$t.+"\t\t".'<td>'.$size[0].'x'.$size[1].'</td>'."\n\r";
	$t=$t.+"\t\t".'<td align="right">'.round(filesize($imgdir.'/'.$a_img[$x])/1000,1).'KB</td>'."\n\r";
	$t=$t.+"\t".'</tr>'."\n\r";
	echo $t;
}

?>
  Send a message via Yahoo to BrianG Send a message via MSN to BrianG  
Reply With Quote