Is there a way to toggle the “Hidden” or “Read-Only” switches on a Windows file using PHP?


As the title says, is there a way to toggle the "Hidden" or "Read-Only" switch on Windows using PHP?

I'd like to do this without opening a shell exec() if possible.


A file can't be hidden, it's always in the file system. There's the *NIX convention that files starting with a . are not shown by default for certain operations (like the ls command), but only if you don't look hard enough. The same goes for Windows, but Windows handles it with file meta attributes.

What you can/should do is use file permissions to make the folder/file inaccessible to anybody who has no business accessing it. Use chmod, chown and chgrp to do so from PHP. You may have to learn a bit about proper file system permissions though.

To make a file "hidden" on Windows you can use

attrib +h yourfile.ext

To make a file "read-only" on Windows you can use

attrib +r yourfile.ext

To use these commands from PHP you just execute them using system or exec.

Also see : Attrib

Need Your Help

What is causing Ghostscript to return an error of -100?

c# ghostscript ghostscriptsharp

So, I am using Matthew Ephraim's GhostscriptSharp, which is a simple C# wrapper for the unmanaged Win32 Ghostscript DLL in my ASP.Net MVC project. Some background:

Get product id and product type in magento?

php magento magento-1.7

I am creating magento store. I am beginner in magento. I want to get product id and product input type in my phtml file is this possible? please guide me..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.