Welcome to the Linux community forum and interact with 2 million technical staff. In this article, we will share a function that can obtain the server-side file or file read/write permissions. I hope it will help you. PHP function :? Phpfunctionfile_permission ($ filename) {$ permsfileperms ($ filename); if ($ perms0xC000)
Welcome to the Linux community forum and interact with 2 million technical staff> in this article, we will share a function that can obtain the server-side file or file read and write permissions. I hope it will help you. PHP function :? Php function file_permission ($ filename) {$ perms = fileperms ($ filename); if ($ perms 0xC000)
Welcome to the Linux community forum and interact with 2 million technicians>
This article describes a function that can obtain the read and write permissions of files on the server.
PHP functions:
Function file_permission ($ filename ){
$ Perms = fileperms ($ filename );
If ($ perms & 0xC000) = 0xC000) {$ info ='s ';}
Elseif ($ perms & 0xA000) = 0xA000) {$ info = 'l ';}
Elseif ($ perms & 0x8000) = 0x8000) {$ info = '-';}
Elseif ($ perms & 0x6000) = 0x6000) {$ info = 'B ';}
Elseif ($ perms & 0x4000) = 0x4000) {$ info = 'D ';}
Elseif ($ perms & 0x2000) = 0x2000) {$ info = 'C ';}
Elseif ($ perms & 0x1000) = 0x1000) {$ info = 'P ';}
Else {$ info = 'U ';}
$ Info. = ($ perms & 0x0100 )? 'R ':'-');
$ Info. = ($ perms & 0x0080 )? 'W ':'-');
$ Info. = ($ perms & 0x0040 )? ($ Perms & 0x0800 )? 'S ': 'X '):
($ Perms & 0x0800 )? 'S ':'-'));
$ Info. = ($ perms & 0x0020 )? 'R ':'-');
$ Info. = ($ perms & 0x0010 )? 'W ':'-');
$ Info. = ($ perms & 0x0008 )? ($ Perms & 0x0400 )? 'S ': 'X '):
($ Perms & 0x0400 )? 'S ':'-'));
$ Info. = ($ perms & 0x0004 )? 'R ':'-');
$ Info. = ($ perms & 0x0002 )? 'W ':'-');
$ Info. = ($ perms & 0x0001 )? ($ Perms & 0x0200 )? 'T': 'X '):
($ Perms & 0x0200 )? 'T ':'-'));
Return $ info;
}
?>
Call method:
$ FileName = "myFile. php ";
Echo file_permission ($ fileName );
?>