Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Dont output directory's hidden files of my PC (http://www.go4expert.com/forums/dont-output-directorys-hidden-files-pc-t26206/)

narekm 4Jul2011 15:29

Dont output directory's hidden files of my PC
 
Hello ...I just was trying to output the file names of different folders in my PC using PHP code...But I found that it outputs actually more than visible files in that particular folder..So what did I mean by visible that when I count the number of files in my folder it appears 18 but when i output it appears that the numer is 20. That two files are not visible. One if the is "Folder.jpg" and the second of them is a ".doc" file i opened and think it is inserted by "Administrator".....This is the code
Code:

<?php

 function getDirectoryList ($directory) 
  {

        // create an array to hold directory list
        $results = array();

        // create a handler for the directory
        $handler = opendir($directory);

        // open directory and walk through the filenames
        while ($file = readdir($handler)) {

          // if file isn't this directory or its parent, add it to the results
          if ($file != "." && $file != "..") {
                $results[] = $file;
          }

        }

        // tidy up: close the handler
        closedir($handler);

        // done!
  return $results;

  }
  $array_1=getDirectoryList("C:\Documents and Settings\Администратор\Мои документы\Downloads");

 
 foreach($array_1 as $value)
 {
 echo "<br/>".$value;
 }
?>

So here is my question ...how can I output only that 18 files and not that invisible files ? Since I want to work only with files that I see.

Please be gentle and help me.

ManzZup 4Jul2011 19:19

Re: Dont output directory's hidden files of my PC
 
i guess you can scan for something like the file attributes but it will slow down the process

pein87 5Jul2011 04:42

Re: Dont output directory's hidden files of my PC
 
I don't think those resrictions are for php or the C file system functions. Those are just for the user.I personally don't know what can be done to stop this problem a side from reading some meta data from the file and seeing if that returns any data on its status. I think that stuff is stored in the registry and only certain files are hidden so you can't just declare a type. If you use this for a website though you could write a log file and then set certain files as hidden based on name or extension. If you do write a log make sure its in a json style so it can simply be included into the file.


All times are GMT +5.5. The time now is 08:45.