我使用下面的表格将多张图片上传到我的服务器。
<form name="addimageForm" id="addimageForm" method="post" action="" enctype="multipart/form-data">
Gallery Image:
<input name="image_name[]" type="file" id="image_name" multiple="true">
<input type="submit" name="addCatImage"/>
</form>
但我很困惑我应该如何遍历它,以便我可以在我的数据库中插入多个图像。我使用了下面的代码,当我运行它时,即使我选择了一个图像,我的表中也会插入 4 行。我认为它正在插入所有数组字段(名称、大小、tmp_name)。我该如何解决这个问题?
foreach ($_FILES[image_name] as $file) {
$access->uploadSubCatImages();
}