返回获取当前目录及......登陆

获取当前目录及新建目录

肖凌2019-10-07 15:04:3523


<!DOCTYPE html>

             <?php 

             //获取当前目录名

             $dir = opendir(__DIR__);

             ?>

<html>

             <head>

                     <title>create dir</title>

                     <style type="text/css">

                     *{margin:0;padding: 0;}

                     div{margin: 30px auto;width: 400px;}

                     input{margin: 0 10px;}

                     </style>

             </head>

             <body>

             <div>

                     <form action="dir.php" method="post">

                     <p>请输入文件夹名:<input type="text" name="floder"><input type="submit" name="submit"></p>

                     </form>

             </div>

             <hr>

             <div>

                     <?php

                             while ($item = readdir($dir)) {

                                          echo '<p>'.$item.'<br></p>';

                             }

                     ?>

             </div>

             </body>

             <?php

                     //获取请求的文件名

                     @$floder = $_REQUEST['floder'];

                     //未填文件名,不操作

                     if(!empty($floder)){

                             //目录名存在就跳转到当前页面

                             if(is_dir($floder)){

                                     echo "<script>alert('目录已存在!');location.href='dir.php';</script>";

                                      return;

                             }else{

                                     mkdir($floder);

                                      header('location:dir.php');

                             }

                     }

             ?>

</html>


最新手记推荐

• 依赖注入小例子• 模板显示用户信息表,并分页显示• 模板继承,模仿php页面• 模拟用户登录验证的案例 依赖注入 Facade• 创建一个验证器, 用来对模型对应的表中字段进行验证处理

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • PHP中文网