【发布时间】:2011-04-16 19:40:25
【问题描述】:
在谷歌上没有找到答案,所以这是我在尝试其他方法之前的最后一次尝试。
我有一个这样的脚本:
// 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");
}
}
为了让它工作,我将上传目录及其所有文件和目录修改为 777(这里有更好的建议吗?)
long 类型的计算结果为“images”,这是一个已经在服务器上创建的目录。
现在,脚本创建以 year 命名的文件夹,权限为 341。这不是我想要的,因为它终止了递归文件夹的构建或阻止了它的内容。
有什么帮助或建议吗?
php版本:5.2.5
配置命令 : './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=/opt/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' '--wit h-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'
【问题讨论】:
标签: php permissions chmod mkdir