Open SeonHyungJo opened 4 years ago
<!DOCTYPE html> <html> <head></head> <body> <input type="file" id="filebtn" value="upload" /> <input type="button" id="btn" value="Download" /> </body> <script> function download(file) { const name = file.name; const blob = new Blob([file]); const url = URL.createObjectURL(blob); const element = document.createElement('a'); element.setAttribute('href', url); element.setAttribute('download', name); document.body.appendChild(element); element.click(); document.body.removeChild(element); } document.getElementById("btn").addEventListener("click", function () { const file = document.getElementById("filebtn").files download(file[0]); }) </script> </html>