php - Verify Files in a folder -


i want verify files stored in directory, wrote script.

<?php $files = scandir('..'); ($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, if include script deeper directory fails.

-www  |_sou    |_inner      |_moreinner 

my script located in inner folder , want access moreinner folder using include shows error file not found/ permission denied

  • what want sha1_file of files stored in above directory.

using recurisvedirectoryiterator elegant way:

$it = new recursivedirectoryiterator('..', filesystemiterator::current_as_fileinfo | filesystemiterator::skip_dots); foreach (new recursiveiteratoriterator($it, recursiveiteratoriterator::self_first) $item) {     if (!$item->isdir()) {         $hash = sha1_file($item->getrealpath());     } else {         $hash = 'dir';     }     echo $item->getrealpath().' '.$hash.' '.date ("f d y h:i:s.", $item->getmtime())."\n"; } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -