文件夹权限777无法正常工作

时间:2016-08-30 07:46:17

标签: php linux directory file-permissions

在托管服务器中,我们为文件夹设置了777权限,但是我们无法在文件夹中写入文件,而且我们还检查了is_writable php代码以检查权限,

<?php
$count = 0;
for($digit=0; $count<2001; $digit+=1){

        $jsondata = trim(file_get_contents("http://www.reddit.com/new/.json?count=$count&limit=100"));

        $json = json_decode($jsondata, true);

        $postdata[$digit] = $json['data']['children'];
        $mergedArray = array_merge($mergedArray, $postdata[$digit]);

        }

        foreach($mergedArray as $livedata){

            $output .= $livedata["data"]["ups"].", ";
            $output .= '"'.$livedata["data"]["title"].'", ';
            $output .= $livedata["data"]["id"].", ";
            $output .= $livedata["data"]["num_comments"].", ";
            $output .= $livedata["data"]["domain"]."\n\r";
            $output .= "<br />";

        }
        echo $output;
        ?>

但它的显示&#34;不可写&#34;

2 个答案:

答案 0 :(得分:1)

检查该文件夹的selinux上下文(命令:ls -Z / directory_path)
对于apache http,假设为 httpd_sys_content_t 。如果未设置,则将其更改为此。

  

chcon -h system_u:object_r:httpd_sys_content_t / directory_path

答案 1 :(得分:0)

你可以查看你的文件名。或文件路径。

使用你的风格是正确的。

也许有点粗心。感谢。

<?php
$file= 'try.txt'; 
if (is_writable($file)) {    
echo 'writable';
} else {    
echo 'not writable';}
?>