const buttonSelect = document.querySelector('.upload-files');
const fileInput = document.querySelector('.file-input');
buttonSelect.addEventListener('click', ()=>{
fileInput.click()
$('.img-container').css('display', 'flex')
});
fileInput.addEventListener('change', (event)=>{
event.preventDefault();
array_for_flask.push(...fileInput.files);
ShowFiles();
});
function del(name) {
const name_img = name.getAttribute('name');
const index = array_for_flask.findIndex(element => element.name === name_img);
$(`#${name_img}`).outerHTML = "";
array_for_flask.splice(index, 1);
console.log(array_for_flask)
};
function ShowFiles(){
const UploadDiv = document.querySelector('.img-container');
UploadDiv.innerHTML = array_for_flask.map(images =>{
const fileReader = new FileReader();
const id = `F-${Math.random().toString(32).substring(7)}`;
fileReader.readAsDataURL(images);
fileReader.onload = ()=>{
const url = fileReader.result;
const name_img = images.name;
const img = `
<img id = '${name_img}' name = '${name_img} 'id='${id}' src = '${url}' alt = 'image' onclick='del(this)'>
`;
UploadDiv.innerHTML +=img;
};
}).join('');
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha512-MV7K8+y+gLIBoVD59lQIYicR65iaqukzvf/nwasF0nqhPay5w/9lJmVM2hMDcnK1OnMGCdVK+iQrJ7lzPJQd1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="static/css/style.css">
</head>
<body>
<div class = 'logo' id = 'navbar'>
<h1>Ayesha</h1>
</div>
<section class="instruction">
<div class="text-block">
<h1>Admin</h1>
</div>
<div class="pic-block">
</div>
</section>
<div class ='card'>
<div class="text-in-card">
<h1>New Coth</h1>
</div>
<div class="name-cloth">
<ion-icon id = 'name-error' name="alert-circle-outline" class = 'error'></ion-icon>
<input id = 'name' type="text" value="" class="some-input" placeholder="name">
<ion-icon name="shirt-outline" class = 'icons-inp'></ion-icon>
</div>
<div class="description-cloth">
<ion-icon id = 'desc-error' name="alert-circle-outline" class = 'error'></ion-icon>
<textarea id = 'desc' placeholder="description" id="" cols="30" rows="1" maxlength="50"></textarea>
<ion-icon name="document-text-outline" class = 'icons-inp'></ion-icon>
</div>
<div class="count-cloth" >
<ion-icon id = 'count-error' name="alert-circle-outline" class = 'error'></ion-icon>
<input id = 'count' type="text" value="" class="some-input" placeholder="count">
<ion-icon name="layers-outline" class = 'icons-inp'></ion-icon>
</div>
<div class="price-cloth" >
<ion-icon id = 'price-error' name="alert-circle-outline" class = 'error'></ion-icon>
<input id = 'price' type="text" value="" class="some-input" placeholder="price">
<ion-icon name="card-outline" class = 'icons-inp'></ion-icon>
</div>
<div class = 'img-container'>
</div>
<div class="upload">
<button class = 'upload-files'><ion-icon name="images-outline"></ion-icon></button>
<input class = 'file-input' type="file" name = 'files' multiple accept='image/*' hidden>
<button class="upload-btn">
Upload
</button>
</div>
</div>
<div class="social-media">
<ion-icon class = 'git' name="logo-github"></ion-icon>
<ion-icon class = 'vk' name="logo-vk"></ion-icon>
<ion-icon class = 'ds' name="logo-discord"></ion-icon>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
<script src="static/js/script.js"></script>
</body>
</html>
Uncaught ReferenceError: array_for_flask is not defined
array_for_flask
, а у тебя она не объявлена, соответственно все что дальше вообще не выполняется. Не знаю какая картинка у тебя там появляется...