In general, there is the following code https://jsfiddle.net/xyz78apr/
function readImagesURL(input) { if (input.files) { for (var i = 0; i < input.files.length; i++) { (function(file) { var reader = new FileReader(); reader.onload = function(e) { var id = $('.image').length; var image = '<div class="col-sm-2">'; image += '<img src="'+e.target.result+'" class="image_upload_preview img-thumbnail">'; image += '<input type="file" id="image-'+id+'" class="image" name="file['+id+']" value="'+e.target.result+'" accept="image/*">'; image += '<button type="button" class="change_img btn btn-block btn-primary">Изменить</button>'; image += '</div>'; $('.gallery .row').append(image); } reader.readAsDataURL(file); })(input.files[i]); } } } The problem is that when sending to the server I get an empty array. For example, I chose 3 images to upload, I get
["file"]=> array(5) { ["name"]=> array(3) { [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" } If after performing readImagesURL, the image is manually changed to a single image, then it gets to the server, if in the loop, then an empty array.
The idea is to make it so that we choose an unlimited number of images to upload, we get a preview, and each image can be changed before uploading to the server.
var_dump($_FILES);- Guestvar_dump($_FILES);and so far, there is no further sense to move, the array is empty: ( - Guest