Reputation: 114
In hosting server we set a 777 permission for folders, but we can't write the files in folders, and also we check the is_writable php code to check the permission,
if (is_writable($dir)) {
echo $dir, ' is writable';
} else {
echo $dir, ' is NOT writable';
}
but its showing "is NOT writable"
Upvotes: 0
Views: 1600
Reputation: 450
Check the selinux context (command: ls -Z /directory_path) of that folder.
It is suppose to be httpd_sys_content_t for apache http. If it is not set then change it to this.
chcon -h system_u:object_r:httpd_sys_content_t /directory_path
Upvotes: 1
Reputation: 2560
you can check your filename. or file path.
Bacuse your using style is correct.
Maybe a little careless. Thanks.
<?php
$file= 'try.txt';
if (is_writable($file)) {
echo 'writable';
} else {
echo 'not writable';}
?>
Upvotes: 0