Setting folder permissions in Windows via PHP

2020-05-06 07:39发布

Is there a way to properly set folder permissions via PHP on a Windows filesystem, such as granting user A full access, and user B read-only on folder \\fileserver\shares\users\A\

I can't seem to find any PHP functions for Windows filesystems for PHP

Any ideas?

2条回答
Fickle 薄情
2楼-- · 2020-05-06 08:17

If you have the ability to call command-line processes, you could use SetACL (if you need very detailed control) otherwise, CACLS is built in.

查看更多
成全新的幸福
3楼-- · 2020-05-06 08:22

Despite using the Unix file permission syntax, PHP's chmod() function does work in Windows (I just tested it).

If your user A was the file owner and user B wasn't then it would be easy to grant one set of permissions to user A and different permissions to user B. You can set the owner of a file using the chown() function (again, Unix-like syntax, but works with Windows, subject to your PHP program having sufficient permissions to itself to make the change).

Hope that helps.

查看更多
登录 后发表回答