Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:32:16+00:00 2026-05-23T12:32:16+00:00

I want to verify files stored in a directory, so i wrote this script.

  • 0

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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:32:16+00:00Added an answer on May 23, 2026 at 12:32 pm

    Using a RecurisveDirectoryIterator would be the most elegant way:

    $it = new RecursiveDirectoryIterator('..', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS);
    foreach (new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST) as $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";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to verify that the images, css, and javascript files that are part
After downloading files from a remote UNIX FTP server, you want to verify that
I want to verify that my understanding is correct. This kind of thing is
I have an XSD and I want to verify incoming XML files from a
Want to just confirm on following. Please verify if this is correct: 1. As
I want to verify if a computer is running .net 3.5 or 3.5 sp1,
I want to verify whether an e-mail is real or not. Some body told
I want to verify if I'm in the last cell of the UITable. Should
Originally, I just want to verify that session_start locks on session. So, I create
so I'm in a little over my head right now and want to verify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.