Getting File Permissions in PHP
PHP has an built-in function to know the permissions assigned to it. Take a look at the following code
echo fileperms("test.txt");
?>
Out Put the above code is
33206
To get permissions in octal value
echo substr(sprintf("%o",fileperms("test.txt")),-4);
?>
Out Put the above code is
1777
Changing Permissions of a file
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);
// Read and write for owner, read for everybody else
chmod("test.txt",0644);
// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);
// Everything for owner, read for owner's group
chmod("test.txt",0740);
?>
Labels: file permissions in php, php, php file permissions
posted by adityachandra @ 9:26 AM,
Post a Comment