Detect if the folder or file is hidden or not in Windows with PHP

Asked

Viewed 80 times

3

I’m listing Windows directories with scandir() of PHP, this way shows all items of the location, and would like to know if it is possible to check whether the folder or file displayed by PHP is hidden in Windows.

  • If you want this information, why did you choose scandir?

  • because I use her array to return with json to another page

  • There is a way to do without the scandir, see in this discussion https://stackoverflow.com/a/28681410/10304819

  • 1

    @Andrélins this was one of the most disgusting things I’ve ever seen in my life :D , using operating system commands to get the information. Not portable, not safe and still disabled in any minimally decent accommodation.

  • @Andrélins still want the array to have hidden folders and files, but to add along to them a variable pointing if it is hidden or not, for this I just need to know one way if it is or not, the rest I take a way kkk

  • I’ve never used it, but I’ve seen it in some places, so I brought the kkk option. How bad it would be to mention it there and the in the php comment. D

  • 3

    @Andrélins ah yes, bring the link is always good, but that is ugly, is :D - But as it comes to PHP, often only has ugly way to do certain things - I hope that comes some answer here that is "less ugly", if there is one. I can’t remember anything specific about PHP to read attributes of this type.

  • 4

    In the list of disgusting solutions there is this: exec("dir \"{$path}\" /A:-H /B", $result); (alternating the -H for H to take the unseen and the occult separately).

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.