The only issue with the code below - it creates one record if no image was selected. It's not supposed to proceed the code if no one image is chosen. This method works fine with single type image form.
if(!empty($_FILES['gallery']['name'])) {
for ($i=0; $i < count($_FILES['gallery']['tmp_name']); $i++) {
$gallery_tmp = $_FILES['gallery']['tmp_name'][$i];
$gallery = time().$_FILES['gallery']['name'][$i];
move_uploaded_file($gallery_tmp, "../uploads/$gallery");
$sql = mysqli_query($database->connection, "INSERT INTO gallery (img) VALUES ('$gallery')");
}
}
HTML code is below:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="gallery[]" class="form-control" multiple="multiple">
<input type="submit" name="submit" value="Update" class="">
</form>