Drag & Drop Upload
A drop zone that lists dropped files with name and size.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:340px"><div class="card-body">
<div class="border border-2 border-dashed rounded-3 text-center p-4" id="duZone" style="cursor:pointer;transition:.2s"><div class="fs-2">☁️</div><div class="small fw-semibold">Drop files or click</div><input type="file" id="duInput" multiple hidden></div>
<ul class="list-group list-group-flush mt-2 small" id="duList"></ul>
</div></div>var zone=document.getElementById('duZone'),input=document.getElementById('duInput'),list=document.getElementById('duList');
zone.onclick=function(){input.click()};
['dragover','dragenter'].forEach(function(ev){zone.addEventListener(ev,function(e){e.preventDefault();zone.classList.add('bg-light','border-primary')})});
['dragleave','drop'].forEach(function(ev){zone.addEventListener(ev,function(e){e.preventDefault();zone.classList.remove('bg-light','border-primary')})});
function add(files){[].forEach.call(files,function(f){var li=document.createElement('li');li.className='list-group-item d-flex justify-content-between px-0';li.innerHTML='<span>'+f.name.replace(/[<>&]/g,'')+'</span><span class="text-secondary">'+(f.size/1024|0)+' KB</span>';list.appendChild(li)})}
zone.addEventListener('drop',function(e){add(e.dataTransfer.files)});
input.addEventListener('change',function(){add(input.files)});Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.