-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileUpload.html
64 lines (62 loc) · 2.22 KB
/
fileUpload.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
<html>
<head>
<title>ArcelorMittal File Upload</title>
<script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script>
<link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css" />
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"
></script>
</head>
<script>
//Ensure that the user is logged in
document.addEventListener("DOMContentLoaded",function(){
let url = new URL(decodeURI(location.href));//Get url
if( url.searchParams.get('u') != null || url.searchParams.get('p') != null){
let Formdata = new FormData();
let username = url.searchParams.get('u');
let password = url.searchParams.get('p');
Formdata.append("username", username);
Formdata.append("password", password);
$.ajax({
method: "Post",
url: "Login.php",
data: Formdata,
cache: false,
processData: false,
contentType: false,
success: function(x){
if(x == "false"){ //Redirect to login page
window.location.href = "login.html";
}
}
});
} else {
window.location.href = "login.html";
}
});
function Upload(){
let file = document.getElementById("file").files[0];
let Formdata = new FormData();
Formdata.append("Data", file);
$.ajax({
url:"fileUploadHandler.php", //php endpoint
data: Formdata,
cache: false,
processData: false,
contentType: false,
method: "POST",
success: function(){
alert("File uploaded succesfully");
}
})
}
</script>
<body>
<div id="fileUpload">
<input type="file" id="file"></br>
<button id="uploadButton" onclick="Upload()">Upload File</button>
</div>
</body>
</html>