• php上传文件


     upload_file.php

    <?php
    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/jpg")))
    //&& ($_FILES["file"]["size"] < 20000))
      {
      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";
      }
    ?>

     index.html

    <html>
    
    <style> 
    .btn{140px;height:36px;line-height:18px;font-size:18px;
    background:url("button_bg.jpg") no-repeat left top;color:#FFF;padding-bottom:4px} 
    </style> 
    
    <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" class="btn"  name="submit" value="Submit"  onmouseover="this.style.backgroundPosition='left -36px'"
     onmouseout="this.style.backgroundPosition='left top'" />
    </form>
    
    </body>
    </html>

    button_bg.jpg

  • 相关阅读:
    Linux中的Diff和Patch
    旧磁带,新风险
    Mac下体验Hexo与Github Pages搭建
    Sublime Text 3 提高工作效率的使用技巧
    PHPExcel对于Excel中日期和时间类型的处理
    做Adsense的一些经验
    使用Fusioncharts实现后台处理进度的前台展示
    iOS: 数据持久化方案
    开发中,理解高内聚、低耦合
    iOS: lame框架将PCM录音转成MP3格式
  • 原文地址:https://www.cnblogs.com/manhua/p/4557243.html
Copyright © 2020-2023  润新知