diff --git a/front.php b/front.php index e2337d9..d461aff 100644 --- a/front.php +++ b/front.php @@ -4,13 +4,12 @@ "> "> -

File Transfer

-
+
Drag and Drop your file or



diff --git a/script.js b/script.js index 98a51b8..0ef58b7 100644 --- a/script.js +++ b/script.js @@ -1,10 +1,9 @@ var fileobj; -function upload_file(e) +function file_dropped(e) { - console.log("droped") e.preventDefault(); fileobj = e.dataTransfer.files[0]; - ajax_file_upload(fileobj); + upload_file(fileobj); } function file_explorer() { @@ -12,7 +11,7 @@ function file_explorer() { document.getElementById('uploadfile').onchange = function() { fileobj = document.getElementById('uploadfile').files[0]; - ajax_file_upload(fileobj); + upload_file(fileobj); }; } @@ -27,23 +26,22 @@ function copytoclipboard() document.execCommand("Copy"); } -function ajax_file_upload(file_obj) +function upload_file(file_obj) { var divresponse = document.getElementById('divresponse'); divresponse.innerHTML = "Uploading file..." ; - $.ajax( - { - type: 'PUT', - url: 'index.php', - contentType: false, - processData: false, - data: file_obj, - success:function(response) - {; - divresponse.innerHTML = response ; - document.getElementById('copytoclipboard').style.visibility = "visible"; - } - }); + 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(); }