I am using the following to try and list all the files in a customers directory. It is supposed to replace $customerID in the path with the customers ID from the previous page that is held in GET, but instead I am getting the error message :
500 –
RecursiveDirectoryIterator::__construct(./customer-files/$customerID,./customer-files/$customerID) [recursivedirectoryiterator.–construct]: The system cannot find the
file specified. (code: 2)
<?php
$customerID = $_GET['customerID'];
echo '<h1>';
echo $customerID;
echo '</h1>';
?>
<?php
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('./customer-files/$customerID')) as $filename)
{
echo '<p>';
echo $filename->getFilename();
echo '</p>';
}
?>
You are using single quotes around your $customerID variable, so you either have to concat, or switch it to double quotes, try this: