zoukankan      html  css  js  c++  java
  • PHP 文件上传

    单文件上传

    <html>
    <body>
    
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" /> 
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    </body>
    </html>
    <?php
    if (in_array($_FILES["file"]["type"],
            ["image/gif", "image/jpeg", "image/pjpeg", 'image/png']
        ) && ($_FILES["file"]["size"] < 2000000))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    
        if (file_exists("upload/" . $_FILES["file"]["name"]))
          {
          echo $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          move_uploaded_file($_FILES["file"]["tmp_name"],
          "upload/" . $_FILES["file"]["name"]);
          echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo "Invalid file";
      }
    ?>
  • 相关阅读:
    环求解点值
    汉诺塔(记录每种路径次数)
    快速排序
    选择排序
    冒泡排序
    桶排序
    异或后最大lowerbit
    计数三角形
    nico和niconiconi
    提高程序设计能力的一般方法
  • 原文地址:https://www.cnblogs.com/fenle/p/4505464.html
Copyright © 2011-2022 走看看