Remove the jquery dependency
This commit is contained in:
parent
cc8bbf6fc6
commit
0677239783
@ -4,13 +4,12 @@
|
||||
<link rel="stylesheet" type="text/css" href="<?php print(_HTTP_PATH . "style.css"); ?> ">
|
||||
<link rel="icon" type="image/x-icon" href="<?php print(_HTTP_PATH . "favicon.ico"); ?> ">
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="<?php print(_HTTP_PATH . "script.js"); ?> "></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>File Transfer</h1>
|
||||
<div id=dragzone class=dragndrop ondrop="upload_file(event);" ondragover="return false" ondragenter="change_color_ondrag('ondragenter');" ondragleave="change_color_ondrag('ondragleave');" >
|
||||
<div id=dragzone class=dragndrop ondrop="file_dropped(event);" ondragover="return false" ondragenter="change_color_ondrag('ondragenter');" ondragleave="change_color_ondrag('ondragleave');" >
|
||||
Drag and Drop your file or <input type="button" value="Select File" onclick="file_explorer();">
|
||||
<input type="file" id="uploadfile" hidden>
|
||||
<br><br><br><br>
|
||||
|
32
script.js
32
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();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user