• 表单提交与接收 文件提交与接收


    构造表单

    <html>  
      <body>
      <div>--------------get--------------------</div>
        <form action="/server.php" method="get" target="_blank">
          checkbox<input type='checkbox' name='checkbox' value='checkbox'></input><br>
          radio<input type='radio' name='radio' value='radio'></input><br>
          image<input type='image' name='image' value='image'></input><br>
          text<input type='text' name='text' value='text'></input><br>
          password<input type='password' name='password' value='password'></input><br>
          hidden<input type='hidden' name='hidden' value='hidden'></input><br>
          button<input type='button' name='button' value='button'></input><br>
          reset<input type='reset' name='reset' value='reset'></input><br>
          submit<input type='submit' name='submit' value='submit'></input><br>
        </form>
      <div>--------------post--------------------</div>
        <form action="/server.php" method="post" target="_blank">
          checkbox<input type='checkbox' name='checkbox' value='checkbox'></input><br>
          radio<input type='radio' name='radio' value='radio'></input><br>
          image<input type='image' name='image' value='image'></input><br>
          text<input type='text' name='text' value='text'></input><br>
          password<input type='password' name='password' value='password'></input><br>
          hidden<input type='hidden' name='hidden' value='hidden'></input><br>
          button<input type='button' name='button' value='button'></input><br>
          reset<input type='reset' name='reset' value='reset'></input><br>
          submit<input type='submit' name='submit' value='submit'></input><br>
        </form>
      </body>
    </html>

    表单接收

    <?php
    if(isset($_GET["submit"]))
    {
        echo "<div>----- get ------</div>";
        foreach($_GET as $tp)
        {
            echo "$tp <br>";
        }
    }
    if(isset($_POST["submit"]))
    {
        echo "<div>----- post ------</div>";
        foreach($_GET as $tp)
        {
            echo "$tp <br>";
        }
    }
    ?>

    构造文件表单

    <html>  
      <body>
        <form action="/server.php" method="post" target="_blank" enctype="multipart/form-data">
        <input type="file" name="picture"></input>
        <input type="submit" name="upload"></input>
        </form>
      </body>
    </html>

    接收文件并保存

    <?php
    //判断文件是否成功上传
    if ($_FILES["picture"]["error"] > 0)
    {
        echo "Error: " . $_FILES["picture"]["error"] . "<br />";
    }
    else
    {
        //输出文件信息
        echo "succeed!<br>";
        echo "Upload: " . $_FILES["picture"]["name"] . "<br />";
        echo "Type: " . $_FILES["picture"]["type"] . "<br />";
        echo "Size: " . ($_FILES["picture"]["size"] / 1024) . " Kb<br />";
        echo "Stored in: " . $_FILES["picture"]["tmp_name"]. "<br />";
        //保存文件
        if (file_exists( $_FILES["picture"]["name"]))
        {
            echo $_FILES["picture"]["name"] . " already exists. ";
        }
        else
        {
            move_uploaded_file($_FILES["picture"]["tmp_name"],$_FILES["picture"]["name"]);
            echo "Stored in: ".$_FILES["picture"]["name"];
        }
    }
    ?>
  • 相关阅读:
    oracle 10g 共享服务器搭建
    Oracle:10053事件简述
    Asktom Oracle: Partition table and index .
    Oracle shared server配置
    Oracle:物化视图语法
    Asktom:Thanks for the question regarding "consistent gets Very puzzling".
    oracle嵌套表整理的学习资料
    非空闲等待事件之:db file sequential read(转)
    Asktom Oracle:How to multiplex single row into multiple rows
    Oracle:Not exists
  • 原文地址:https://www.cnblogs.com/qiusuo/p/5128350.html
Copyright © 2020-2023  润新知