修改php脚本创建的文件的权限

时间:2013-12-01 19:56:40

标签: php file-permissions

我如何(或可以)更改以下php script,以便在创建新文件时,它会为文件r/w提供权限?

<?php
    if(isset($_GET['data'])) {
        $data = $_GET['data']  . "\n";
        $ip = $_GET['ip'];
        $ret = file_put_contents('/opt/tomcat7/webapps/servlets/WEB-INF/logs/' . $ip, $data, LOCK_EX);
        if($ret === false) {
            die('There was an error writing the lab data file');
        }
        else {
            echo "$ret bytes written to file";
        }
    }
    else {
        die('no data to process');
    }
?>

1 个答案:

答案 0 :(得分:0)

尝试chmod功能。

例如chmod("/somedir/somefile", 0755)