I have a form with multiple inputs like this:
<div id="users">
<input type="text" name="title[]" required>
<input type="file" name="images[]">
<input type="text" name="title[]" required>
<input type="file" name="images[]">
<input type="text" name="title[]" required>
<input type="file" name="images[]">
</div>
<input type="button" value="add new user">
<input type="submit" value="submit">
the problem is that selecting image is optional and if the user doesn't select any image for any of titles the posted data would be like this:
title = ["title1","title2","title3"]
images = [image1.jpg,image3.jpg]
the count of users is not fixed and user can add any desired number of titles and images by clicking on the add new user button. so "add new user" button will add a pair of these inputs to users div:
<input type="text" name="title[]" required>
<input type="file" name="images[]">
is there any way to detect if the file is selected or not? or to send a default value for not selected file inputs? I want to set null value for image if no file is selected, like this:
user1:{title="title1",image=image1.jpg}
user2:{title="title2",image=null}
user3:{title="title3",image=image3.jpg}
.
.
.
images[one],images[two]