我试图同时将三个文件上传到我的本地服务器。这是脚本:
<form method="post" action="<?php echo($_SERVER['PHP_SELF']);?>" enctype="multipart/form-data" >
Note: All files are mandatory <br/><br/>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Select first image: <input name="img[]" type="file"/> <br/>
Select second image: <input name="img[]" type="file"/> <br/>
Select third image: <input name="img[]" type="file"/> <br/>
<br/><br/>
<input type="submit" name="submit" value="Go!"/>
</form>
<?php
if (isset($_FILES)) {
for ($key=0; $key<=2; $key++)
{
$tmp_name = $_FILES["img"]["tmp_name"][$key];
$name = $_FILES["img"]["name"][$key];
move_uploaded_file($tmp_name, "img/$name");
}
echo "Done!";
}
?>
我面临两个问题:
Undefined
index: img
知道出了什么问题吗?
答案 0 :(得分:1)
您收到错误2,文件太大,只有第二个文件足够小:
在文件上传下阅读: http://php.net/manual/en/ini.core.php#ini.upload-max-filesize