I know it is easy to see file permissions in php, but I can't find search reference for directory permissions.
Is is possible to display the folder permission and ownership with php?
If anyone can answer please also provide the example code.
Then, do the appropriate chmod to give the group www-data the same permissions as you. For example, if the current mode is 640 (6 for you, 4 for www-data, 0 for others, translating to -rw-r-----), set it to 660 (6 for you, 6 for www-data, 0 for others, translating to -rw-rw----).
To view the permissions for all files in a directory, use the ls command with the -la options. Add other options as desired; for help, see List the files in a directory in Unix. In the output example above, the first character in each line indicates whether the listed object is a file or a directory.
PHP's fileperms function also works with directories, as you can see in Example #2.
echo substr(sprintf('%o', fileperms('/path/to/directory')), -4);
// prints something like 1777
Use fileowner to get the ID of the user who owns the file/directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With