【发布时间】:2011-11-19 18:47:32
【问题描述】:
我在 PHP 中上传多个文件有点问题,
我有这个 html 表单:
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="file" name="myfile[]" />
<input type="submit" />
</form>
这是upload.php:
<?php print_r( $_FILES ); ?>
当我发送文件时,它会显示:
Array
(
[myfile] => Array
(
[name] => Array
(
[0] => Krw_Qe4QKmI.mp3
)
[type] => Array
(
[0] =>
)
[tmp_name] => Array
(
[0] =>
)
[error] => Array
(
[0] => 1
)
[size] => Array
(
[0] => 0
)
)
)
到目前为止一切顺利。
当我将表单升级到这个时,问题就开始了:
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="file" name="myfile[]" />
<input type="file" name="myfile[]" />
<input type="submit" />
</form>
现在,当我发送 2 个文件时,它会显示:
Array
(
)
那么,这里有什么问题? 谢谢你,莫尔。
【问题讨论】:
-
您显示的第一个数组中有错误(代码为
1)。请参阅此处了解其含义:php.net/manual/en/features.file-upload.errors.php
标签: php forms file-upload upload