dongnanman9093 2016-05-12 09:30
浏览 4
已采纳

输入类型=文件是否出现在$ _POST中?

I have this within a form and I was thinking that as its an input name I should be able to detect it with $_POST[] but I cant see it. Which would explain when I do isset on it nothing happens. Am I not understanding it correctly?

<input type="file" id="files" name="files"  class="hidden" multiple="" >
<label for="files">Select file</label>
  • 写回答

2条回答 默认 最新

  • doutu7123 2016-05-12 09:31
    关注

    You can access posted file data in $_FILES

    You can get file name, file type, tmp_name, error, size in $_FILES

    Simple exmaple is:

    Html:

    <form action="upload_manager.php" method="post" enctype="multipart/form-data">
        <h2>Upload File</h2>
        <label for="fileSelect">Filename:</label>
        <input type="file" name="photo" id="fileSelect"><br>
        <input type="submit" name="submit" value="Upload">
    </form>
    

    In php:

    <?php
    if($_FILES["photo"]["error"] > 0){
        echo "Error: " . $_FILES["photo"]["error"] . "<br>";
    } else{
        echo "File Name: " . $_FILES["photo"]["name"] . "<br>";
        echo "File Type: " . $_FILES["photo"]["type"] . "<br>";
        echo "File Size: " . ($_FILES["photo"]["size"] / 1024) . " KB<br>";
        echo "Stored in: " . $_FILES["photo"]["tmp_name"];
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 wordpress如何限制ip访问频率
  • ¥15 自研小游戏,需要后台服务器存储用户数据关卡配置等数据
  • ¥15 请求解答odoo17外发加工某工序的实操方法
  • ¥20 IDEA ssm项目 跳转页面报错500
  • ¥20 系统直接进入应急模式了,请教一下,人要裂开了
  • ¥15 页面初次加载时,JS调用对象可以调用成功,但是一旦跳转到另一个页面,再跳转回来后这个对象就显示undefind了,调用也调用不了了,什么原因?
  • ¥15 来个厉害的程序开发的,安排点活给你做
  • ¥15 rexroth indramotion MTX micro系统轴耦合编程
  • ¥100 springboot2.7.x 整合 sharding 的问题
  • ¥15 如何通过命令行操作统信360安全浏览器?