<?php header("Content_Type:text/html;charset=utf-8");
/*
* Folder
* 文件创建在style/image目录下
*/
$file_path = $_SERVER['DOCUMENT_ROOT']."/wp_php/style/image/";
//create folder
if(!is_dir($file_path."file1")){
if(mkdir($file_path."file1")){
echo "<br> folder create success";
}else{
echo "<br> folder reate fail";
}
}else{
echo "<br> create folder: exist";
}
//create multistep(多级) folder
if(!is_dir($file_path."file2/f1/f2")){
if(mkdir($file_path."file2/f1/f2",0777,true)){
echo "<br> create multistep success";
}else{
echo "<br> create multistep fail";
}
}else{
echo "<br> create multistep(多级): exist";
}
//Create/Delete more folder--array
$dir_array = array($file_path."folder1",$file_path."folder2");
if(!file_exists($file_path."folder1") && !file_exists($file_path."folder2")){
@array_map(mkdir,$dir_array);
echo "<br> Create more folder: success";
}else{
@array_map(rmdir, $dir_array);
echo "<br> Create more folder: exist--delete more folder";
}
//Delete folder--must null
if(is_dir($file_path."file1")){
if(rmdir($file_path."file1")){
echo "<br> Delete folder:success";
}
echo "<br> Delete folder: fail";
}else{
echo "<br> Delete folder: not exist";
}
//打印出目录下所有文件列表
print_r(scandir('<br>'.$_SERVER['DOCUMENT_ROOT']));
/*
Array
(
[0] => .
[1] => ..
[2] => apache_pb.gif
[3] => apache_pb.png
[4] => apache_pb2.gif
[5] => apache_pb2.png
[6] => apache_pb2_ani.gif
[7] => applications.html
[8] => empManage
[9] => favicon.ico
[10] => file
[11] => group
[12] => mcools
[13] => wp_php
[14] => xampp
)
*/
?>