当保存一个文件的时候,文件的权限会被放到一个不存在的地方,最初被创建为新文件。文件权限和CHMOD:如何在创建文件时在PHP中设置777?
现在,这一切顺利,保存的文件似乎有模式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;
}
请注意,0777模式是**危险**。请参阅http://stackoverflow.com/questions/2338641/in-a-php-apache-linux-context-why-exactly-is-chmod-777-dangerous – 2011-06-22 00:54:27
@Phoenix谢谢。我葡萄牙0766就足够了(需要允许所有的写入权限)。那个更好吗? – Sam
0766更好;这将防止任意代码执行。该文件是否需要**世界**可写,或只要例如Apache可以写入文件就足够了?你有一组需要能够写这些文件的应用程序吗?如果你让它们作为同一组运行并设置0764模式呢? – 2011-06-22 01:05:13