extract($_POST);
extract($_GET);
?>
View server-side directories and files < ;meta http-equiv="Content-Type" c text="#000000">
$n = 0;
if (isset($InputDirRoot))
{
$handle=opendir($InputDirRoot);
echo "Directory list:
".$InputDirRoot."
";
while ($ file = readdir($handle))
{
$n ++;
if (is_dir($InputDirRoot."/".$file))
$file = "
[".$file."]";
else
$file = "
".$file."";
echo " ".$file. "
";
}
closedir($handle);
}
if(isset($method) && isset($InputDir) && strcmp($method,"createdir")==0){//Create Directory
if(is_dir($InputDir)){
chmod($InputDir,0777);
echo "The directory already exists! Permissions modified!";
}else{
if(@mkdir("$InputDir")){
echo "Directory creation completed...!";
}else{
echo "Directory creation failed...!" ;
}
chmod($InputDir,0777);
}
}
if(isset($method) && isset($InputDir) && strcmp($method,"uploadfile")==0){//Upload file or Delete file
if(is_file($InputDir."/".$_FILES[UploadFile][name])){
chmod($InputDir."/".$_FILES[UploadFile][name],0777);
echo " The file exists! Deleted!--You can re-upload the file";
unlink($InputDir."/".$_FILES[UploadFile][name]);
}else{
if(@copy($_FILES[UploadFile][tmp_name] ,$InputDir."/".$_FILES[UploadFile][name])){
echo "The file {$_FILES[UploadFile][name]} is correctly copied to {$InputDir}...!";
} else{
echo "File copy failed...!";
}
chmod($InputDir."/".$_FILES[UploadFile][name],0777);
}
}
if(isset($Info) && strcmp($method,"drop")==0){//Delete file or directory
if(is_dir($Info)){
if(rmdir($Info)){
echo "Directory {$Inof} delete Completed";
}else{
echo "The directory cannot be deleted!The reason--maybe there are files in the directory!";
}
}
if(is_file($Info)){
if(unlink($Info)){
echo "File {$Info} has been deleted... !";
}else{
echo "File {$Info} deletion failed...! Try to modify the file permissions to delete...";
if(chmod($Info,0777)){
unlink($Info);
echo "The file {$Info} has been deleted after modifying its permissions...";
}else{
echo "The file {$Info} cannot be deleted through WEB. It may be that the FTP permissions have been set for this file..." ;
}
}
}
}
echo "
";
echo "Total $n items.";
?>
The above has introduced the PHP code for the process of directory creation, deletion, file upload, and deletion on the server side, including PHP code content. I hope it will be helpful to friends who are interested in PHP tutorials.