Appending uploaded files
Moderator: General Moderators
I've done it - thanks for all you help everybody.
My page still needs tidying up, and security features adding, but essentially here is the finished version of view.php:
I put the view.php code inside the subdirectory and then made sure only image files could be displayed - otherwise blank image squares were showing to represent folders and php and html pages - thats what the red squares were.
I'll probably screw this up royally now whilst tidying and be back again...but cheers for your help, it was invaluable.
My page still needs tidying up, and security features adding, but essentially here is the finished version of view.php:
Code: Select all
<?
function CheckExt($filename, $ext) {
$passed = FALSE;
$testExt = "\.".$ext."$";
if (eregi($testExt, $filename)) {
$passed = TRUE;
}
return $passed;
}
$exts = array("gif","jpg$|\\.jpeg","png","bmp");
echo "<b>Images in this folder:</b>";
$dir = opendir(".");
$files = readdir($dir);
while (false !== ($files = readdir($dir))) {
foreach ($exts as $value) {
if (CheckExt($files, $value)) {
echo "<img src='$files' >\n";
$count++;
break;}
}
}
echo $count." image(s) found in this directory.\n";
echo "<a href="".$_SERVER["PHP_SELF"]."">Refresh</a>\n";
closedir($dir);
?>I'll probably screw this up royally now whilst tidying and be back again...but cheers for your help, it was invaluable.