php - 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 本地和我的共享托管域上。
任何可能发生这种情况的想法或可能的原因或如何解决它都将不胜感激。
解决方案
你应该在你的表格中添加
enctype="多部分/表单数据"
推荐阅读
- amazon-web-services - 使用 Glue Connections 连接 Redshift 权限问题
- python - Python中冒号和等号的使用
- python - Python 并发 executor.map() 和 submit()
- javascript - 触发孩子的 onClick 时更改父母状态的更好方法?(反应)
- azure - 关于 Azure 中的异地复制
- javascript - 对象未在 forEach() 方法中推送到数组
- python - Django 模型序列化程序返回 ID
- javascript - 使用 Javascript 添加包含伪元素的类
- vb.net - opentk vb.net 多次旋转和平移
- javascript - 如何根据单个数组元素的条件内容在 javascript 中推送整个数组?