I want to use one or more string functions, such as explode() or substr() or strrchr(), to determine the extension of each file. I want to account for files that might contain four letter extensions, such as .jpeg, or might contain multiple periods in the filename, or might be in upper or mixed case.
If the file is a JPEG or JPG, i want to display the file using HTML image tags. I wanna use a smaller width attribute value, such as 100, and no height attribute, so that the images are scaled by the browser. I dont want to display directories or any other file types. I am new to this php, so any help would be great. I posted the php below
[php]<?php
$dir = “/etc/php5/”;
// Open a known directory, and proceed to read its contents
$dir = “./”;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . “
”;
}
closedir($dh);
}
}
?>[/php]