输入type = files是否出现在$ _POST中? [英] Does input type=files appear in $_POST?

查看:48
本文介绍了输入type = files是否出现在$ _POST中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中包含此内容,并且我认为作为输入名称,我应该可以使用$ _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>

推荐答案

您可以访问 $ _ FILES

您可以在$ _FILES中获取文件名,文件类型,tmp_name,错误,大小

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

简单的例子是:

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>

在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"];
}
?>

这篇关于输入type = files是否出现在$ _POST中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆