note 36876 added to function.readdir
| From: | shortkid422 at coastertrade dot com | Date: | Sat, 25 Oct 2003 22:56:32 +0000 |
| Subject: | note 36876 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59290@lists.php.net to get a copy of this message | ||
Heres a nice auto-thumbnail, non-database, auto-creation gallery, have fun.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Untitled Page</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<?php
// $dir = the absolute directory link (see below example)
$dir = "/home/coastert/public_html/sfgam/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..")
{
// We just took out the links to the other directories (for security reasons and looks)
// Now lets echo all the images into the webpage (note, you can change the hieght and width for
bigger thumbnail size)
// Note, the $file is the file names, so you must link it to the directory so that it can link the
file properly
echo "<a href='http://www.website.com/relative/link/to/directory/$file'><img
src='http://www.website.com/relative/link/to/directory$file'
width='80' height='60' border='0'
alt='$file'> ";
}
}
closedir($dh);
}
}
?>
</BODY>
</HTML>
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36876
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36876&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36876&report=yes
Search -- http://master.php.net/manage/user-notes.php