尝试在服务器上调用 mkdir() 时出现以下错误...
警告:mkdir() [function.mkdir]: Permission denied in /home/server/public_html/wp-content/themes/mytheme/catimages/cat-images.php on line 373
函数如下。它试图在站点的“wp-content/uploads 文件夹”下创建一个文件夹。我已经验证 PHP 版本是 5.2.15 并且主题文件夹中的文件是可写的,但这并不一定意味着上传文件夹是可写的。
如何确定上传文件夹是否可写?
protected function category_images_base_dir()
{
// Where should the dir be? Get the base WP uploads dir
$wp_upload_dir = wp_upload_dir();
$base_dir = $wp_upload_dir[ 'basedir' ];
// Append our subdir
$dir = $base_dir . '/cat-images';
// Does the dir exist? (If not, then make it)
if ( ! file_exists( $dir ) ) {
mkdir( $dir ); //THIS IS LINE 373
}
// Now return it
return $dir;
}