Sam*_*Sam 11 php file-permissions file chmod
保存不存在的文件时的问题文件权限,最初创建为新文件.
现在,一切顺利,保存的文件似乎有模式644.
我需要在这里更改什么才能使文件保存为模式777?
万分感谢任何提示,线索或答案.我认为与此相关的代码包括:
/* write to file */
self::writeFileContent($path, $value);
/* Write content to file
* @param string $file Save content to wich file
* @param string $content String that needs to be written to the file
* @return bool
*/
private function writeFileContent($file, $content){
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
return true;
}
Run Code Online (Sandbox Code Playgroud)
the*_*ist 25
PHP有一个内置的函数叫做 bool chmod(string $filename, int $mode )
private function writeFileContent($file, $content){
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
chmod($file, 0777); //changed to add the zero
return true;
}
Run Code Online (Sandbox Code Playgroud)
您只需手动设置所需的权限chmod():
private function writeFileContent($file, $content){
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
// Set perms with chmod()
chmod($file, 0777);
return true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
94921 次 |
| 最近记录: |