var fileobj; function file_dropped(e) { e.preventDefault(); fileobj = e.dataTransfer.files[0]; upload_file(fileobj); } function file_explorer() { document.getElementById('uploadfile').click(); document.getElementById('uploadfile').onchange = function() { fileobj = document.getElementById('uploadfile').files[0]; upload_file(fileobj); }; } function copytoclipboard() { var elm = document.getElementById("divresponse"); var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(elm); selection.removeAllRanges(); selection.addRange(range); document.execCommand("Copy"); } function upload_file(file_obj) { var divresponse = document.getElementById('divresponse'); divresponse.innerHTML = "Uploading file..." ; const request = async () => { var response = await fetch('/index.php', { method: 'PUT', body: file_obj }); var text = await response.text(); console.log(text); divresponse.innerHTML = text ; document.getElementById('copytoclipboard').style.visibility = "visible"; } request(); } function change_color_ondrag(event) { if (event === "ondragenter") { var element = document.getElementById('dragzone'); element.classList.add("dragover"); } else if (event === "ondragleave") { var element = document.getElementById('dragzone'); element.classList.remove("dragover"); } }