问题描述
我的网站"将包含数千个名为"e"的子目录,这些子目录将保存用户创建的特定于该目录提交表单的.json文件.我需要这个新创建的目录为chmod0007.我该怎么做?
My Website will contain thousands of subdirectories named 'e' which are to hold user created .json files specific to that directory's submission form. I need this newly created directory to be chmod 0007. How can I do this?
下面的代码来自一个php文件,该文件用于本地存储文件夹'e'中的全局存储功能,但仅在该文件夹已经存在且已经chmod 0007时才有效:
This code below comes from a php file the global store function for local storage in folder 'e' but it only works right now if that folder is already there and already chmod 0007:
public function store(Document $document) {
if (!isset($document->id)) { $document->id = $this->generateId(); }
//This is my guess how to do it..
$this->path = $this->path . DIRECTORY_SEPARATOR
if (!file_exists($this->path)) {
mkdir($this->path);
chmod($this->path, 0007);
}
//My guess does not work
$path = $this->getPathForDocument($document->id);
$data = $this->formatter->encode((array) $document);
return file_put_contents($path, $data);
}
注意:我已经通过PHP搜索了与chmod相关的其他堆栈文章,所有文章都是与文件相关的,而不是目录,和/或到目前为止,没有一篇文章足以帮助我.请仅链接到专门回答这个确切问题的内容.
Note: I have searched other stack articles related to chmod via PHP, all are file related, not a directory, and/or none to date have been clear enough to help me. Please only link to something that specifically answers this exact question.
注意:这不是哪个chmod最好的问题.谢谢您对chmod ####的关注,我稍后会考虑.请重点关注问题的答案,而不是一个困扰您的细节,而无需回答.
Note: This is not a question of which chmod is best. Thank you for your chmod #### concerns, I will consider those later. Please focus on an answer to the question, not one detail that bothers you, without answering.
推荐答案
偶然发现:PHP mkdir:
Stumbled on this: PHP mkdir: PHP mkdir: Permission denied problem
他们建议这样做:chown -R www-data:www-data/var/www/example.com/public_html/chmod -R g + rw/var/www/example.com/public_html/
They suggested this: chown -R www-data:www-data /var/www/example.com/public_html/ chmod -R g+rw /var/www/example.com/public_html/
它确实有效.
谢谢:)
这篇关于如何用PHP chmod 0007很多目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!