mirror of
https://github.com/System-End/Team_Website.git
synced 2026-04-20 00:25:24 +00:00
Merge branch 'okokok' into Made-for-Jaden
This commit is contained in:
commit
f798dcc49c
7 changed files with 554 additions and 117 deletions
43
Pages/Callback.html
Normal file
43
Pages/Callback.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Authorization Callback</title>
|
||||
<script>
|
||||
// Parse the authorization code from the URL
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const code = urlParams.get('code');
|
||||
|
||||
// Exchange the authorization code for an access token
|
||||
fetch('https://login.microsoftonline.com/common/oauth2/v2.0/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'client_id': 'c91a3691-c800-4aed-9e85-1a2c896327de',
|
||||
'scope': 'Files.ReadWrite.All',
|
||||
'code': code,
|
||||
'redirect_uri': 'http://localhost:5500/Pages/upload.html',
|
||||
'grant_type': 'authorization_code',
|
||||
'client_secret': 'ddba6e4e-62b1-4a13-b165-08b00ef6723f'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// Save the access token and optionally the refresh token
|
||||
const accessToken = data.access_token;
|
||||
const refreshToken = data.refresh_token;
|
||||
|
||||
// Use the access token to make API requests
|
||||
console.log('Access Token:', accessToken);
|
||||
console.log('Refresh Token:', refreshToken);
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Authorization successful. You can close this window.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<body>
|
||||
<!--Navigation Bar-->
|
||||
<div id="navbar"></div>
|
||||
|
||||
|
||||
<div id="mc_embed_shell">
|
||||
<link
|
||||
href="//cdn-images.mailchimp.com/embedcode/classic-061523.css"
|
||||
|
|
|
|||
112
Pages/shop.html
112
Pages/shop.html
|
|
@ -40,11 +40,113 @@
|
|||
/>
|
||||
</div>
|
||||
|
||||
<div class="UnderConstruction">
|
||||
This section is under construction...
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1>Welcome to Our Online Shop</h1>
|
||||
<div class="products">
|
||||
<div class="product">
|
||||
<img src="hoodie.jpg" alt="Hoodie" />
|
||||
<h2>Hoodies - $45</h2>
|
||||
<label for="hoodie-size">Select Size:</label>
|
||||
<select id="hoodie-size">
|
||||
<option value="Xsmall">XSmall</option>
|
||||
<option value="small">Small</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="large">Large</option>
|
||||
<option value="Xlarge">XLarge</option>
|
||||
<option value="XXlarge">XXLarge</option>
|
||||
<option value="XXXlarge">XXXLarge</option>
|
||||
</select>
|
||||
<label for="hoodie-quantity">Quantity:</label>
|
||||
<input
|
||||
type="number"
|
||||
id="hoodie-quantity"
|
||||
name="hoodie-quantity"
|
||||
min="0"
|
||||
/>
|
||||
</div>
|
||||
<div class="product">
|
||||
<img src="tshirt.jpg" alt="T-Shirt" />
|
||||
<h2>T-Shirts - $15</h2>
|
||||
<label for="tshirt-size">Select Size:</label>
|
||||
<select id="tshirt-size">
|
||||
<option value="Xsmall">XSmall</option>
|
||||
<option value="small">Small</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="large">Large</option>
|
||||
<option value="Xlarge">XLarge</option>
|
||||
<option value="XXlarge">XXLarge</option>
|
||||
<option value="XXXlarge">XXXLarge</option>
|
||||
</select>
|
||||
<label for="tshirt-quantity">Quantity:</label>
|
||||
<input
|
||||
type="number"
|
||||
id="tshirt-quantity"
|
||||
name="tshirt-quantity"
|
||||
min="0"
|
||||
/>
|
||||
</div>
|
||||
<button id="checkout-button">Checkout</button>
|
||||
<div class="order-summary">
|
||||
<h2>Your Order Summary:</h2>
|
||||
<p id="order-summary"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div id="socials"></div>
|
||||
<script>
|
||||
var stripe = Stripe(
|
||||
"sk_test_51PBMFWCZYaFRUYezJHsiqgp6BHarFfhZjlNkDT8MNnxSOpCe3pDR427dyqYJMmEIF5JRe6aQc16KxHK3euoMZ9de00r03MbmAR"
|
||||
);
|
||||
var checkoutButton = document.getElementById("checkout-button");
|
||||
checkoutButton.addEventListener("click", function () {
|
||||
var hoodieSize =
|
||||
document.getElementById("hoodie-size").value;
|
||||
var hoodieQuantity = parseInt(
|
||||
document.getElementById("hoodie-quantity").value
|
||||
);
|
||||
var tshirtSize =
|
||||
document.getElementById("tshirt-size").value;
|
||||
var tshirtQuantity = parseInt(
|
||||
document.getElementById("tshirt-quantity").value
|
||||
);
|
||||
var totalPrice = hoodieQuantity * 45 + tshirtQuantity * 15;
|
||||
|
||||
// Create a Stripe Checkout session
|
||||
stripe.redirectToCheckout({
|
||||
items: [
|
||||
{
|
||||
sku: "sku_HOODIE",
|
||||
quantity: hoodieQuantity,
|
||||
size: hoodieSize,
|
||||
},
|
||||
{
|
||||
sku: "sku_TSHIRT",
|
||||
quantity: tshirtQuantity,
|
||||
size: tshirtSize,
|
||||
},
|
||||
],
|
||||
successUrl: "https://yourwebsite.com/success",
|
||||
cancelUrl: "https://yourwebsite.com/cancel",
|
||||
clientReferenceId: "unique_id", // optional
|
||||
payment_method_types: ["card"],
|
||||
mode: "payment",
|
||||
lineItems: [
|
||||
{
|
||||
quantity: hoodieQuantity,
|
||||
price: "price_HOODIE",
|
||||
description: "Hoodie - " + hoodieSize,
|
||||
},
|
||||
{
|
||||
quantity: tshirtQuantity,
|
||||
price: "price_TSHIRT",
|
||||
description: "T-Shirt - " + tshirtSize,
|
||||
},
|
||||
],
|
||||
submit_type: "pay",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- Footer -->
|
||||
<div id="socials"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
49
Pages/shopconstruction.html
Normal file
49
Pages/shopconstruction.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<html>
|
||||
<head>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/x-icon"
|
||||
href="/Resources/Favicons/favicon.png"
|
||||
/>
|
||||
<link rel="stylesheet" href="/Pages/style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<script>
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
fetch("/Pages/navbar.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("navbar").innerHTML = data;
|
||||
});
|
||||
fetch("/Pages/socials.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("socials").innerHTML = data;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!--Navigation Bar-->
|
||||
<div id="navbar"></div>
|
||||
|
||||
<!-- Body -->
|
||||
<div class="Title-Container">
|
||||
<h1 class="page-title" style="width: 100%; text-align: center">
|
||||
Shop
|
||||
</h1>
|
||||
<img
|
||||
src="/Resources/Icons/team-icon.png"
|
||||
id="TeamIcon"
|
||||
alt="Team Icon"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="UnderConstruction">
|
||||
This section is under construction...
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div id="socials"></div>
|
||||
</body>
|
||||
</html>
|
||||
202
Pages/style.css
202
Pages/style.css
|
|
@ -1,11 +1,15 @@
|
|||
@font-face {
|
||||
font-family: OpenSans;
|
||||
src: url("../Resources/openSans.ttf");
|
||||
font-family: OpenSans;
|
||||
src: url("../Resources/openSans.ttf");
|
||||
}
|
||||
|
||||
html {
|
||||
background-color: #e0e0e0;
|
||||
font-family: OpenSans;
|
||||
background-color: #e0e0e0;
|
||||
font-family: OpenSans;
|
||||
}
|
||||
|
||||
/*SCROLLBAR*/
|
||||
|
|
@ -626,3 +630,201 @@ h2 {
|
|||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* shop css */
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 20px;
|
||||
color: #333;
|
||||
}
|
||||
.products {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.product {
|
||||
flex-basis: 45%;
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.product img {
|
||||
max-width: 100%;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
input[type="number"] {
|
||||
width: calc(50% - 5px);
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
input[type="submit"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
input[type="submit"]:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
.order-summary {
|
||||
margin-top: 30px;
|
||||
border-top: 1px solid #ccc;
|
||||
padding-top: 20px;
|
||||
}
|
||||
#order-summary {
|
||||
font-weight: bold;
|
||||
}
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 20px;
|
||||
color: #333;
|
||||
}
|
||||
.products {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.product {
|
||||
flex-basis: 45%;
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.product img {
|
||||
max-width: 100%;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
input[type="number"] {
|
||||
width: calc(50% - 5px);
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
input[type="submit"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
input[type="submit"]:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
.order-summary {
|
||||
margin-top: 30px;
|
||||
border-top: 1px solid #ccc;
|
||||
padding-top: 20px;
|
||||
}
|
||||
#order-summary {
|
||||
font-weight: bold;
|
||||
}
|
||||
/* end shop css */
|
||||
/*@-webkit-keyframes fill {
|
||||
0% {
|
||||
width: 0%;
|
||||
height: 1px;
|
||||
}
|
||||
50% {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
}
|
||||
100% {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(163, 47, 47);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/*Upload Page*/
|
||||
.container {
|
||||
margin: 50px auto;
|
||||
width: 80%;
|
||||
text-align: center;
|
||||
}
|
||||
.upload-btn {
|
||||
padding: 10px 20px;
|
||||
background-color: #c5203d;
|
||||
color: #000;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 5px; /* Optional, for rounded corners */
|
||||
}
|
||||
.up-btn {
|
||||
padding: 10px 20px;
|
||||
background-color: #c5203d;
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
border-radius: 5px; /* Optional, for rounded corners */
|
||||
}
|
||||
input[type="file"] {
|
||||
display: none;
|
||||
}
|
||||
#uploaded-image {
|
||||
max-width: 500px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
@ -1,106 +1,132 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/x-icon"
|
||||
href="/Resources/Favicons/favicon.png"
|
||||
/>
|
||||
<link rel="stylesheet" href="/Pages/style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script>
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
fetch("/Pages/navbar.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("navbar").innerHTML = data;
|
||||
});
|
||||
fetch("/Pages/socials.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("socials").innerHTML = data;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="navbar"></div>
|
||||
|
||||
<div class="container">
|
||||
<h2>Image Uploader</h2>
|
||||
<p>Here you can upload pictures of the team. Thank you for your suppourt</p>
|
||||
<form action=" " method="post" enctype="multipart/form-data">
|
||||
<label for="file-upload" class="upload-btn">Choose Image</label>
|
||||
<input type="file" id="file-upload" name="file" accept="image/*">
|
||||
<br>
|
||||
<br>
|
||||
<button type="submit" class="up-btn">Upload</button>
|
||||
</form>
|
||||
<div id="image-preview">
|
||||
<h3>Uploaded Image:</h3>
|
||||
<img id="uploaded-image" src="#" alt="Uploaded Image">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Replace with your OneDrive API credentials
|
||||
const clientId = 'YOUR_CLIENT_ID';
|
||||
const redirectUri = 'YOUR_REDIRECT_URI';
|
||||
const scopes = 'Files.ReadWrite.All';
|
||||
var f;
|
||||
document.getElementById('file-upload').addEventListener('change', function(event) {
|
||||
const fileInput = event.target;
|
||||
const file = fileInput.files[0];
|
||||
const reader = new FileReader();
|
||||
f = file;
|
||||
reader.onload = function(e) {
|
||||
const imagePreview = document.getElementById('uploaded-image');
|
||||
imagePreview.src = e.target.result;
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
function getToken() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = `https://login.microsoftonline.com/common/oauth2/v2.0/token`;
|
||||
|
||||
// Make a POST request to get an access token
|
||||
axios.post(url, {
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
scope: scopes,
|
||||
grant_type: 'client_credentials'
|
||||
})
|
||||
.then(response => {
|
||||
resolve(response.data.access_token);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
<head>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/x-icon"
|
||||
href="/Resources/Favicons/favicon.png"
|
||||
/>
|
||||
<link rel="stylesheet" href="/Pages/style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script>
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
fetch("/Pages/navbar.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("navbar").innerHTML = data;
|
||||
});
|
||||
fetch("/Pages/socials.html")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("socials").innerHTML = data;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function uploadToOneDrive(accessToken) {
|
||||
const url = 'https://graph.microsoft.com/v1.0/me/drive/root:/path/to/upload/' + f.name + ':/content';
|
||||
function signInWithMicrosoft() {
|
||||
window.open(
|
||||
"https://login.microsoftonline.com/common/oauth2/v2.0/authorize?" +
|
||||
"client_id=c91a3691-c800-4aed-9e85-1a2c896327de" + // Replace with your client ID
|
||||
"&response_type=code" +
|
||||
"&redirect_uri=http://localhost:5500/Pages/Callback.html" + // Replace with your redirect URI
|
||||
"&scope=openid%20offline_access%20Files.ReadWrite.All",
|
||||
"_blank"
|
||||
);
|
||||
}
|
||||
|
||||
// Prepare the request headers
|
||||
const headers = {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
'Content-Type': f.type
|
||||
};
|
||||
function uploadFile() {
|
||||
var fileInput = document.getElementById("fileInput");
|
||||
var file = fileInput.files[0];
|
||||
if (file) {
|
||||
var formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
// Make a PUT request to upload the file
|
||||
axios.put(url, f, { headers: headers })
|
||||
.then(response => {
|
||||
console.log('File uploaded successfully:', response.data);
|
||||
alert('File uploaded successfully!');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error uploading file:', error.response.data.error);
|
||||
alert('Error uploading file. See console for details.');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div id="socials"></div>
|
||||
</body>
|
||||
</html>
|
||||
// Include access token in the request header
|
||||
var accessToken =
|
||||
document.getElementById("accessToken").value; // Access token obtained after authentication
|
||||
fetch(
|
||||
"https://graph.microsoft.com/v1.0/me/drive/root:/Photos/" +
|
||||
file.name +
|
||||
":/content",
|
||||
{
|
||||
method: "PUT",
|
||||
body: formData,
|
||||
headers: {
|
||||
Authorization: "Bearer " + accessToken,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
alert("File uploaded successfully!");
|
||||
} else {
|
||||
alert("Error uploading file!");
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error("Error:", error));
|
||||
} else {
|
||||
alert("Please select a file to upload.");
|
||||
}
|
||||
}
|
||||
|
||||
// Function to preview the selected image
|
||||
function previewImage() {
|
||||
var fileInput = document.getElementById("fileInput");
|
||||
var file = fileInput.files[0];
|
||||
if (file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
document.getElementById("previewImage").src =
|
||||
e.target.result;
|
||||
document.getElementById("previewImage").style.display =
|
||||
"block";
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!--Navigation Bar-->
|
||||
<div id="navbar"></div>
|
||||
<h1>Upload Photos to OneDrive</h1>
|
||||
<input
|
||||
type="file"
|
||||
id="fileInput"
|
||||
accept="image/*"
|
||||
onchange="previewImage()"
|
||||
/>
|
||||
<button onclick="uploadFile()">Upload</button>
|
||||
<img id="previewImage" style="display: none; max-width: 300px" />
|
||||
<a href="#" onclick="signInWithMicrosoft()"
|
||||
>Click here to sign in with Microsoft</a
|
||||
>
|
||||
|
||||
<!-- Access Token Field (Hidden) -->
|
||||
<input type="hidden" id="accessToken" />
|
||||
|
||||
<!-- Script to Get Access Token from Callback URL -->
|
||||
<script>
|
||||
// Function to parse URL parameters
|
||||
function getParameterByName(name, url) {
|
||||
if (!url) url = window.location.href;
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return "";
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
// Get the access token from the URL and store it
|
||||
var accessToken = getParameterByName("code");
|
||||
if (accessToken) {
|
||||
document.getElementById("accessToken").value = accessToken;
|
||||
// Optionally, you can automatically trigger the file upload here
|
||||
// uploadFile();
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Footer -->
|
||||
<div id="socials"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,28 @@
|
|||
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData();
|
||||
const files = document.getElementById('fileInput').files;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
formData.append('files', files[i]);
|
||||
document.getElementById('uploadButton').addEventListener('click', function() {
|
||||
var fileInput = document.getElementById('fileInput');
|
||||
var file = fileInput.files[0];
|
||||
if (file) {
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
// Include access token in the request header
|
||||
var accessToken = '0.ARwAw2-U4FdM706UscGv35A33ZE2GskAyO1KnoUaLIljJ97OAKE.AgABBAIAAADnfolhJpSnRYB1SVj-Hgd8AgDs_wUA9P-hUr5BU4lmnr4DEs3ouZjfl75d0wqoBoJGS_R9hgiFpCdVlC4HawyM5-B0iFUcA-z-QU8vxUK4aU8m-0zBm6UEZpWjZViQqJUoUQX0IC1DASg0P7w8_t9N77tcvm-8edmYqDchaRM3DFZsDCukNneKZuvRQEPDItZLguMG9U0T2YEG5tGRzjRnWla67XcbO7XxgkBh-mK4BpxNzNczNF54SShx8NAEz323Ye69oJb8S5bKmN2GSuBYgfgOUBzAzOwiVmE4KwZKIDxVObzC2ynX84Oiv32u4xKAtQYKoPykJCDoTdl7RRuyYOcq-dTq9nTHXzU8GuV0RFhYkqwP6q5bhCeCRCxQdnpei4KR-c8MesEC6Fl37tDwGgrf_ZWk8ldOrD8ld7NnjKa6V_LX8mDSCRB_yOdtLBOrKLDcSik4CCQxLPzDX0BrWc-MGF9Z4YjJSWNR6rPeF3wpEGI5vCFa7TPwojJsAG-Y5aE3qXbSkOe_Y-Z5iqJapnUWA7iIfLRROg97Fam4HUFKMLaA1lKmAbsDJi9Bbo7mvW1If2frASNiQ5gtJ5_UHojgiQS1Uj0KqPzkT3giqlHaIP96qXfWpteQdnhgM1kKpIqlbbETtvCDxzTEqIGwrhXZM3t80lp9w0v3eRtr3YeF4exwj0eSWz8LqOxitbsCzjOfbItOIOdQm407-udFqf0aiWRntkuEeWlhlfhWIR_2KGivnuSCiJdayM8ENsDI8MZDNU8NrPiuFOCu01NKyNzTOyIKu6Zbj6WTohVi2aYUL7oWy0G4zOCAQvOgsj9icEbolFttUL-_Ac5ISskzFbHXJnWrljK3FVjhDgCjWcMJOYJIUYaJxO6pPcyJHR_Q2vMXRWEkFuyyLARzP0ZBjevOKzS4YCN7HJLx6_c4W6CygOO3vNoYIJDt5iWCOHt__aD-XmgLbvgLDIczVFLWGPDd7Ddtql_GdvSPTONs8sO_5NAzwQNHwH2_odiz'; // Replace with your actual access token
|
||||
fetch('https://graph.microsoft.com/v1.0/me/drive/root:/Photos/' + file.name + ':/content', {
|
||||
method: 'PUT',
|
||||
body: formData,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + accessToken
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
alert('File uploaded successfully!');
|
||||
} else {
|
||||
alert('Error uploading file!');
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
} else {
|
||||
alert('Please select a file to upload.');
|
||||
}
|
||||
await fetch('http://your-server-address/upload', { // Update server address here
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
alert('Files uploaded successfully!');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue