PHP多文件上传

PHP多文件上传,php,file-upload,Php,File Upload,文件上传的HTML: <form enctype="multipart/form-data" action="" method="POST"> <br/>Upload Featured Image: <input name="imagefiles" type="file" /><br/> <br/>Upload Gallery Image 1: <input nam

文件上传的HTML:

 <form enctype="multipart/form-data" action="" method="POST">
                <br/>Upload Featured Image: <input name="imagefiles" type="file" /><br/>
                <br/>Upload Gallery Image 1: <input name="imagefiles" type="file" /><br/>
                <br/>
                <input type="submit" name="submit" value="Add Product" />

</form>
但是,我得到了这个错误:

Warning: Invalid argument supplied for foreach() in /var/www/html/addProductForm.php on line 25 (Edit)

您使用的参数名称不正确。 您必须添加
[]
以使输入成为一个数组,否则最后一个元素将覆盖具有相同名称的先前元素

请尝试下面的HTML:

<form enctype="multipart/form-data" action="" method="POST">
   <br/>Upload Featured Image: <input name="imagefiles[]" type="file" /><br/>
   <br/>Upload Gallery Image 1: <input name="imagefiles[]" type="file" /><br/>
   <br/>
   <input type="submit" name="submit" value="Add Product" />
</form>


上传特色图片:

上传画廊图片1:


我假设“--->[文件中的第25行]”不是代码的一部分?@Brendon Cheves,是的,你是对的!!
<form enctype="multipart/form-data" action="" method="POST">
   <br/>Upload Featured Image: <input name="imagefiles[]" type="file" /><br/>
   <br/>Upload Gallery Image 1: <input name="imagefiles[]" type="file" /><br/>
   <br/>
   <input type="submit" name="submit" value="Add Product" />
</form>