- 论坛徽章:
- 0
|
原帖由 wanjunq 于 2008-7-21 12:26 发表 ![]()
我已经把文件夹设为可写,并且apache的用户已经改成管理愿,用is_writeable判断一个目录总返回false,那位能解决下吗?
据说是由于此函数在某些情况下有bug
有人自己写了一个:
<?php
function is__writable($path) {
if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
return is__writable($path.uniqid(mt_rand()).'.tmp');
else if (is_dir($path))
return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
// check tmp file for read/write capabilities
$rm = file_exists($path);
$f = @fopen($path, 'a');
if ($f===false)
return false;
fclose($f);
if (!$rm)
unlink($path);
return true;
}
?> |
注意判断目录要在最后加上 / |
|