I want to verify files stored in a directory, so i wrote this script.
<?php
$files = scandir('..');
for ($i=0;$i<count($files);$i++)
{
$file2 = realpath($files[$i]);
if (!is_dir($file2))
$hash = sha1_file($file2);
else
$hash = 'Dir';
echo '<tr><td>'.$i.'</td><td>'.$file2.'</td><td>'.$hash.'</td><td>'.date ("F d Y H:i:s.",filemtime($file2)).'</td></tr>';
$i;
}
?>
it works nice, but if i include this script from a deeper a directory then it fails.
-www
|_Sou
|_Inner
|_MoreInner
my script is located in inner folder and want to access it from MoreInner folder using include but it shows error FILE NOT FOUND/ PERMISSION DENIED
- What i want to do
To get SHA1_FILE of files stored in the just above directory.
Using a
RecurisveDirectoryIteratorwould be the most elegant way: