开发者

php creates folder with 341 permissions

Didn't got any luck finding an answer on google , so this is my last try before trying other methods.

I have a script like this:

        // get current year and month
        $cur_year = date('Y');
        $cur_month = date('m');
        $long_type = $this->getFile_longtype();

        $folder = $_SERVER['DOCUMENT_ROOT']."/".FOLDER_CMS."/uploads/$long_type/$cur_year/$cur_month";

        // check whether the folder exists
        if(!is_dir($folder)){

            // try to make the folder recursively
            if(!mkdir($folder,"0777",true)){

                logError($message, __FILE__, __LINE__);
                throw new Exception("Failure creating proper directories");

            }

        }

to make it work , I chmod'ed the uploads directory and all it's files and dirs to 777 ( beter suggestion here? )

The long type evaluates to 'images' and this is a directory has already been created on the server.

Now , the script create the folder named with year with the permissions 341. This not wat I want because it terminates the recursive folder buildup or blocks it's content from me.

Any help or suggestions?

php version : 5.2.5

configure command : './configure' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-pdo=shared' '--enable-soap' '--enable-sockets' '--enable-wddx' '--enable-zip' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libexpat-dir=/usr' '--with-libxml-dir=/op开发者_如何转开发t/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mhash=/opt/mhash/' '--with-mssql=/usr/local/freetds' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-png-dir=/usr' '--with-pspell' '--with-sqlite=shared' '--with-tidy=/opt/tidy/' '--with-ttf' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr'


Don't use the string "0777", use 0777.


As mentioned by Alex, you suppose to enter OCTAL value not a STRING also, for security reasons never give full permission to folders use 0755 instead.


The real permissions depend on the parameter to mkdir and the umask. The umask is subtracted from the permissions given to mkdir. Try setting your umask to 0 before doing the mkdir.


I have also just encountered this issue where PHP sets the permissions to 1314, despite mkdir being set to 0755. This issue was that the folders that were being created were under a parent folder with the permissions 0700. When I changed the permissions with mkdir to 0700 it created the folders with the correct permissions. So it seems (quite logically) you cannot permission a child folder with greater permissions than it's parent.

In your case, a parent folder was probably set to 0755 and you were attempting to create a child with 0777.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜