我有像
这样的HTML<form action="send.php" method="post" enctype="multipart/form-data">
<div>
<label for="subject">Subject</label>
<input type="text" name="subject" />
</div>
<div>
<label for="image">Image</label>
<input type="file" name="image" />
</div>
<input type="submit" value="Send" />
</form>
我为null
获得了$_FILES
为什么会这样?
答案 0 :(得分:6)
在表单部分中,请确保您拥有以下代码:enctype =“multipart / form-data”
答案 1 :(得分:5)
<?php print_r($_FILES);?>
<form action="" method="post" enctype="multipart/form-data">
<div>
<label for="subject">Subject</label>
<input type="text" name="subject" />
</div>
<div>
<label for="image">Image</label>
<input type="file" name="image" />
</div>
<input type="submit" value="Send" />
</form>
检查上面的代码:
它应该产生以下输出:
Array
(
[image] => Array
(
[name] => ezwebin_userguide.pdf
[type] => application/pdf
[tmp_name] => C:\Windows\Temp\php1485.tmp
[error] => 0
[size] => 1073054
)
)
答案 2 :(得分:0)
您是否尝试过回显更具体的数据? 例如:
echo $_FILES["file"]["error"]
或者
echo $_FILES["file"]["name"]
问候。
答案 3 :(得分:0)
在php.ini中可能关闭了file_uploads。试试这个脚本:
<?php
echo 'file_uploads: '. ini_get('file_uploads'). '<br />';
echo 'upload_tmp_dir: '. ini_get('upload_tmp_dir'). '<br />';
echo 'upload_max_filesize: '. ini_get('upload_max_filesize'). '<br />';
echo 'max_file_uploads: '. ini_get('max_file_uploads'). '<br />';
?>
答案 4 :(得分:0)
我遇到了同样的问题,没有一个主题是我的错误。检查.htaccess文件,如果有的话,如果启用了“MultiViews”。我不得不禁用它们。