首页 > 解决方案 > PHP - $_FILES 没有出现

问题描述

我的网站上有一个相当简单的表格。只是一个文本输入和一个文件输入。

<form action='myFile.php' method='POST'>
    <input type='text' id='image_description' name='image_description'>
    <input type='file' id='image' name='image'>
    <button onclick="this.form.submit();">Submit</button>
</form>

当我提交时,我有var_dump($_POST)and var_dump($_FILES)

我可以看到我在文本字段中输入的所有内容,但文件似乎没有通过。

array(2) {
    ["image_description"]=> string(4) "test"
    ["image"]=> string(14) "Untitled-1.png"
}

array(0) {

}

这发生在 WAMP 本地和我的共享托管域上。

任何可能发生这种情况的想法或可能的原因或如何解决它都将不胜感激。

标签: phpfilepost

解决方案


你应该在你的表格中添加

enctype="多部分/表单数据"


推荐阅读