文件上传成功!
"; } else { echo "文件上传失败!
"; } } // 处理创建目录 if (isset($_POST['folder_name'])) { $folder_name = $_POST['folder_name']; if (!is_dir($dir . DIRECTORY_SEPARATOR . $folder_name)) { mkdir($dir . DIRECTORY_SEPARATOR . $folder_name); echo "文件夹 '$folder_name' 创建成功!
"; } else { echo "文件夹 '$folder_name' 已经存在!
"; } } // 处理删除文件或文件夹 if (isset($_POST['delete'])) { $delete_item = $_POST['delete']; $delete_path = $dir . DIRECTORY_SEPARATOR . $delete_item; if (is_dir($delete_path)) { rmdir($delete_path); // 删除目录 echo "文件夹 '$delete_item' 删除成功!
"; } elseif (file_exists($delete_path)) { unlink($delete_path); // 删除文件 echo "文件 '$delete_item' 删除成功!
"; } } // 处理重命名文件或文件夹 if (isset($_POST['rename']) && isset($_POST['new_name'])) { $old_name = $_POST['rename']; $new_name = $_POST['new_name']; $old_path = $dir . DIRECTORY_SEPARATOR . $old_name; $new_path = $dir . DIRECTORY_SEPARATOR . $new_name; if (rename($old_path, $new_path)) { echo "文件 '$old_name' 重命名为 '$new_name' 成功!
"; } else { echo "文件重命名失败!
"; } } // 处理编辑文件 if (isset($_POST['edit_file']) && isset($_POST['file_content'])) { $file_to_edit = $_POST['edit_file']; $file_path = $dir . DIRECTORY_SEPARATOR . $file_to_edit; file_put_contents($file_path, $_POST['file_content']); echo "文件 '$file_to_edit' 内容更新成功!
"; } // 获取文件内容以便编辑 $file_content = ''; $file_to_edit = ''; if (isset($_POST['edit'])) { $file_to_edit = $_POST['edit']; $file_path = $dir . DIRECTORY_SEPARATOR . $file_to_edit; if (file_exists($file_path)) { $file_content = file_get_contents($file_path); } } // 处理进入目录 if (isset($_POST['enter_dir'])) { $subdir = $_POST['enter_dir']; $dir = realpath($dir . DIRECTORY_SEPARATOR . $subdir); } ?>名称 | 操作 | 属性 | "; if (is_dir($filePath)) { echo "$file"; // 显示文件夹名称 echo ""; } else { echo "$file"; } echo " | "; echo ""; echo " | 权限: $filePerm 修改时间: $fileTime 大小: $fileSize | ";
echo "";
}
?>
---|