-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.html
121 lines (101 loc) · 2.67 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<script>
/*
* By Pedram [ Pedroxam ]
*/
// Replace your server url and remote.php file
const SERVER_API = "https://example.com/remote.php"
</script>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Remote Upload File</title>
<link rel="stylesheet" type="text/css" href="./style.css">
<script src="./jquery.min.js"></script>
</head>
<body>
<div id="upload">
<h2>Upload Now !</h2>
<form id="remote">
<fieldset>
<p><label for="link">Link</label></p>
<p><input type="url" id="url" name="url" placeholder="http://example.com/file.zip" required autocomplete="off"></p>
<p><label for="link">Filename</label></p>
<p><input type="text" id="name" name="name" placeholder="file.zip" required autocomplete="off"></p>
<p><input type="submit" value="Upload" name="send" class="Button"></p>
</fieldset>
</form>
<div id="result">
Progress: <span class="progress">--</span>
<br/>
<br/>
Uploaded: <span class="uploaded">--</span>
<br/>
<br/>
Filesize: <span class="filesize">--</span>
</div>
</div>
<script>
// Global Progress var
var doProgress;
let check = getDownload();
if(check !== "" && check !== null){
doProgress = setInterval(getProgress, 2500);
}
function getProgress(){
$.ajax({
url: SERVER_API + '?progress=1',
dataType: 'json',
type: 'POST',
data: {
name: (check !== "" && check !== null) ? check : $('#name').val()
},
success:function(data){
$('#result .progress').html(data.progress + ' %');
$('#result .uploaded').html(data.uploaded);
$('#result .filesize').html(data.size);
if(data.progress >= 100){
clearInterval(doProgress); // Stop Progress Var
$('#result').html('File Succesfully Uploaded.');
delDownload();
}
},
})
}
$(document).ready(function(){
$('#remote').submit(function(e){
e.preventDefault();
if($('#url').val() === '') return;
if($('#name').val() === '') return;
$.ajax({
url: SERVER_API,
dataType: 'json',
type: 'POST',
data: $(this).serialize(),
beforeSend:function()
{
$('.Button').attr('disabled',true);
saveDownload($('#name').val());
doProgress = setInterval(getProgress, 2500);
},
success:function(data){
$('.Button').attr('disabled',false);
if(!data.status){
$('#result').html('Sorry, Please Check your server config.');
}
},
})
});
});
function saveDownload(value) {
window.localStorage.setItem('download', value);
}
function getDownload() {
return window.localStorage.getItem('download');
}
function delDownload() {
window.localStorage.removeItem('download');
}
</script>
</body>
</html>