Greetings All,
I am writing a php script that reads the contents of a folder and writes the files to the screen as a link. The folder has many files but the naming convention is the same. It is:
randomNumber_Date_Time.pdf
I need to scan the files and if the randomNumber is equal to the querystring input value, then display the file as a link on the page.
The random number can be from 1 to 9 digits in length. Here is the code snippet I am trying to get working.
<?php
$dir = "./inspection/";
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
//if (substr($file,strpos($file,'_')) == $_GET['qQID']) {
echo substr($file,stripos($file,'_')) . "<br>";
echo "<a href=\"./inspection/" . $file . "\">" . $file . "</a><br>";
//}
}
}
closedir($handle);
}
?>
Thanks for looking!
John