Hi guys,
I am trying to scan a folder & create a dropdown list which contains the contents of the folder but when I run the script there is nothing in the dropdown list.
I have created a function which is below: -
<?php
function pricelist('c:/htdocs/panasonic_system_pricing') {
// Execute code if the folder can be opened, or fail silently
if ($contents = @ scandir('c:/htdocs/panasonic_system_pricing')) {
// initialize an array for matching files
$found = array();
// Create an array of file types
$fileTypes = array('jpg','jpeg','gif','png','pdf','xls','doc');
// Traverse the folder, and add filename to $found array if type matches
$found = array();
foreach ($contents as $item) {
$fileInfo = pathinfo($item);
if (array_key_exists('extension', $fileInfo) && in_array($fileInfo['extension'],$fileTypes)) {
$found[] = $item;
}
}
// Check the $found array is not empty
if ($found) {
// Sort in natural, case-insensitive order, and populate menu
natcasesort($found);
foreach ($found as $filename) {
echo "<option value='$filename'>$filename</option>\n";
}
}
}
}
?>[/B]
Any ideas?