Da się to jakoś ogarnąć?
0
1
Zrób console.log(this) i zobacz po czym iterujesz.
0
jak zrobię console.log tutaj
$('#images').on('change', function (e) {
if (this.files) {
console.log(this)
zwraca
<input id="images" type="file" name="images[]" accept="image/*" placeholder="Kliknij lub przeciągnij zdjęcia" multiple="multiple" style="display: none;">
0
Po czym iterujesz
czyli co masz w pętli for
jako this
.
0
nie wiem czy dobrze rozumiem. Mam zrobić console.log w pętli for czyli tutaj?
$('#images').on('change', function (e) {
if (this.files) {
let filesAmount = this.files.length;
for (let i = 0; i < filesAmount; i++) {
console.log(this)
let file = this.files[i];
storedFiles.push(file);
let reader = new FileReader();
reader.onload = function (event) {
let html = '<div class="single-image-preview" style="margin-bottom: 5px; position: relative!important;"> <button type="button" class="remove-img button-remove-image">x</button><img src="' + event.target.result + '" style="width: 100%"></div>';
$(html).insertAfter('#imagesPreview');
const self = this;
$(".remove-img").click(function(e){
e.preventDefault();
$(this).parent().remove('');
});
}
reader.readAsDataURL(this.files[i]);
}
}
})
0
Tobra to może inaczej.
let file = this.files[i];
Console.log(file);
0
zwraca
<input id="images" type="file" name="images[]" accept="image/*" placeholder="Kliknij lub przeciągnij zdjęcia" multiple="multiple" style="display: none;">
0
o to chodziło?