note 17887 added to ref.dir
| From: | sareu_gif at yahoo dot es | Date: | Mon, 31 Dec 2001 15:46:53 +0000 |
| Subject: | note 17887 added to ref.dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-24018@lists.php.net to get a copy of this message | ||
The resource wrote and sent by ian@directone.com.au notes back,
for to list images files with their thumbnails is very good.
It hat a problem only. Don´t reconize
the images thumbnails have spaces in the name file like:
example image.gif
This one be repair making a little change in the code. For example changing this...
<img
src=$thumbnail_directory_name$thumbnail_prefix$file></td>";
for this...
><img
src='$thumbnail_directory_name$thumbnail_prefix$file'></td>";
Thanks for your routine ian@directone.com.au
the code complete is below:
<html>
<head>
<META HTTP-EQUIV=\"expires\" CONTENT=\"Mon, 01 Jan 2001
01:00:00 GMT\">
<style>
a,body,td,p,br {font-family:verdana,arial,geneva; font-size:10pt}
</style>
</head>
<body>
<?
/*
second thingo in $accepted_types can be:
y - show thumbnail
n - don't show anything
some_image - to show a generic image
*/
$accepted_types = array( ".gif"=>"y",
".jpg"=>"y",
".mpg"=>"mov.gif" );
$images_per_row = 2;
if ( is_dir('./thumbnails') )
{
$thumbnails = true;
// some programs such as Graphic Workshop put a prefix on scaled images
$thumbnail_prefix = "S_";
// make sure you have the trailing /
$thumbnail_directory_name = "./thumbnails/";
}
$handle = opendir('.');
echo "
<i><b>Image Files:</b></i>
Click on the link to see the image
<hr>
";
// index value used together with $images_per_row
// to see if we should skip to the next row
$i = 0;
echo "<table border=0 cellpadding=2><tr>";
while ( ( $file = readdir($handle) )!== false )
{
// Don't show '.' and '..'
if ( $file != "." && $file != ".." )
{
$extension = strtolower(substr($file,strpos($file,".")));
// is this file type in the accepted types array?
if ( $accepted_types[$extension] )
{
$file_size = floor(filesize ($file) / 1024);
if ( $i>0 && is_integer($i/$images_per_row) )
$beginning = "\n</tr>\n<tr>\n";
else
$beginning = "";
echo "$beginning<td><a
href=$file>$file</td><td>$file_size
k</a></td>";
if ( $thumbnails && ($accepted_types[$extension]=='y') )
echo "<td><img
src='$thumbnail_directory_name$thumbnail_prefix$file'></td>";
else if ( $thumbnails && ($accepted_types[$extension]=='n') )
echo "<td><font size=-2> </td>";
else if ( $thumbnails )
echo "<td><font size=-2><img
src='$thumbnail_directory_name$accepted_types[$extension]'></td>";
$i++;
}
}
}
echo "</table>";
closedir($handle);
?>
</body>
</html>
--
http://www.php.net/manual/en/ref.dir.php
http://master.php.net/manage/user-notes.php?action=edit+17887
http://master.php.net/manage/user-notes.php?action=delete+17887
http://master.php.net/manage/user-notes.php?action=reject+17887