【问题标题】:$_FILES super global variable$_FILES 超级全局变量
【发布时间】:2021-08-02 12:44:30
【问题描述】:

为什么 unset 函数在上传文件后不删除 $_FILES 内容或清空它。 上传文件后如何清空我的 $FILES 变量。

<html>
    <head>
            <title>Files Upload</title>
    </head>
    <body>
            <form action="" method="post" enctype="multipart/form-data">
                <input type="file" name="pdf" id="pdf"><br>
                <input type="submit" name="sumbit" value="upload">
            </form>
    </body>
</html>
<?php
unset($GLOBALS['$_FILES']);
echo "<pre>";
var_dump($_FILES);
echo "</pre>";
?>

The Output is :
array(1) {
  ["pdf"]=>
  array(5) {
    ["name"]=>
    string(19) "Courses Degrees.pdf"
    ["type"]=>
    string(15) "application/pdf"
    ["tmp_name"]=>
    string(24) "C:\xampp\tmp\php6BBD.tmp"
    ["error"]=>
    int(0)
    ["size"]=>
    int(624129)
  }
}

【问题讨论】:

  • 如果你var_dump($GLOBALS);,你会看到文件在_FILES,而不是$FILES
  • 您的编辑在 _FILES 上仍有美元符号
  • 这些我都试过了
  • 你试过$_GLOBALS['_FILES']?嗯

标签: php file superglobals


【解决方案1】:

你必须指定变量的键

unset($_FILES['key']);

查看输出时,您的密钥可能是“pdf”

unset($_FILES['pdf']);

【讨论】:

  • 我要一步删除所有键
  • 你有一个数组数组。 $_FILES ("pdf") 的第一行包含所有不同的文件。
  • 谢谢..这是真的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-14
  • 1970-01-01
  • 2019-08-21
  • 1970-01-01
  • 2016-09-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多