如何用php chmod 0007 很多目录? [英] How to chmod 0007 a lot of directories with php?

查看:21
本文介绍了如何用php chmod 0007 很多目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站将包含数千个名为e"的子目录,这些子目录用于保存用户创建的特定于该目录提交表单的 .json 文件.我需要这个新创建的目录是 chmod 0007.我该怎么做?

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: 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 很多目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆