Sean wrote:
> Thanks Ric,
>
> Fast response!
>
> Will try that later, but certainly looks the ticket for me.
>
>
> "Ric" <antispam@randometry.com> wrote in message
> news:ekmajl$76l$1@online.de...
> > Sean schrieb:
> >> Could anyone advise me if it's possible (with PHP) to list the files that
> >> appear in a folder.
> >>
> >> What I want to acheive is a webpage that will display all of the images
> >> from
> >> within the /gallery/ directory of the website that I am working on.
> >
> > If you just want to read files inside a given dir:
> >
> > http://de3.php.net/manual/en/function.readdir.php
> >
> >
> > If you want to also list the folders, use:
> >
> > http://de3.php.net/manual/en/function.scandir.php
> >>
> >> Regards,
> >>
> >> Sean
> >>
> >>
> >>
> >>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="../stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<br><br>
<div>
<?php
$simpleAuth = ( isset($_REQUEST['letmein']) ? $_REQUEST['letmein'] :
0);
if ( $simpleAuth > 1 ) {
$pathStr = $_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"];
$dir = substr($pathStr, 0, strrpos($pathStr, "/")+1);
$aThisDir = explode('/',$dir);
$cThisDir = $aThisDir[count($aThisDir)-2];
//HTTP_HOST
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$pos = strrpos($filename, ".");
if ( ( is_dir($filename) && $filename != ".") ||
substr($filename, strrpos($filename, "."), strrpos($filename,
".")+3) == ".gif" ||
substr($filename, strrpos($filename, "."), strrpos($filename,
".")+3) == ".jpg" ||
substr($filename, strrpos($filename, "."), strrpos($filename,
".")+3) == ".png"
) {
echo "<div>";
echo "<a href='".rawurlencode($filename)."'>".$filename."</a>";
echo "</div>";
}
}
}
?>
</div>
</body>
</html>