Php mkdir()未在linux服务器上创建文件夹
没错,我的本地服务器是WindowsServer2012,但当我在linux服务器上托管的时候,我已经在工作了 当用户提交表单时,它应该运行以下代码 代码:Php mkdir()未在linux服务器上创建文件夹,php,mkdir,Php,Mkdir,没错,我的本地服务器是WindowsServer2012,但当我在linux服务器上托管的时候,我已经在工作了 当用户提交表单时,它应该运行以下代码 代码: 在我的windows服务器上,您看到的每一个/i都使用了目录分隔符,但由于是linux,所以需要将其更改为正斜杠。这现在不起作用了。任何dieas为什么?目录分隔符根据您使用的操作系统确定斜杠需要使用的方式。从Windows到Linux,您不需要更改它们,这就是它们的全部意义。也就是说,您应该需要使用目录分隔符,PHP非常聪明,能够计算出斜
在我的windows服务器上,您看到的每一个/i都使用了目录分隔符,但由于是linux,所以需要将其更改为正斜杠。这现在不起作用了。任何dieas为什么?目录分隔符根据您使用的操作系统确定斜杠需要使用的方式。从Windows到Linux,您不需要更改它们,这就是它们的全部意义。也就是说,您应该需要使用目录分隔符,PHP非常聪明,能够计算出斜杠的方向,并在需要时进行转换。您是否拥有足够的权限?是否检查了服务器日志文件以查看是否存在任何错误?基本调试:查看正在构建的路径。不要直接在mkdir调用中构建/使用它们。分别构建它们,以便可以捕获值$路径=$target\u dir$裁判。等echo$path;mkdir$path.infact可能是文件夹的权限,让我检查一下
$target_dir = "docs". "/";
//IF/ELSE the folder is already created...
if(!file_exists($target_dir . $ref . "/"))
{//Create folder named 1 inside the customer ref folder.
mkdir($target_dir . $ref . "/" . "1" . "/", 0775, true);
$count = 0;
}else
{//Create new folder inside customer ref folder
//count the amount of folders inside docs/$ref/
$find_folders = glob($target_dir . $ref . "/" . "*",GLOB_ONLYDIR);
$count = count($find_folders);
//create new folder inside $ref/ using count+1 to make the folder increase by 1
$new_folder = $count +1;
mkdir($target_dir . $ref . "/" . $new_folder . "/", 0775, true);
}
//IF count exists then the $target_file changes to the new folder...
if($count > 0)
{
$target_file = $target_dir . $ref . "/" . $new_folder . "/";
}else
{//else use first directory
$target_file = $target_dir . $ref . "/" . "1" . "/";
}