uploaded images saved to Pi

This commit is contained in:
Neythen
2021-10-07 20:40:43 +01:00
parent 3fb1ee197a
commit acd46c0aef
10 changed files with 66 additions and 6 deletions

View File

@@ -486,11 +486,22 @@ var allFeaturesFileAddBtn = [
null,
];
var uploaded_images = [];
var uploaded_GIFs = [];
allFeaturesFileAddBtn.map((value, index) => {
if (value !== null) {
value.addEventListener("click", () => {
var tag = document.createElement("li");
tag.innerHTML = allFeaturesFile[index].files[0].name;
if (index == 10) {
uploaded_images.push(allFeaturesFile[index].files[0]);
} else if (index == 11) {
uploaded_GIFs.push(allFeaturesFile[index].files[0]);
}
allFeatures[index].appendChild(tag);
changeVarValue();
@@ -685,6 +696,35 @@ function saveSettings() {
method:"PUT",
body:JSON.stringify(settings)
});
//send uploaded images and gifs
if (pageNum == 11){
var data = new FormData();
for ( var i = 0; i < uploaded_images.length; i++ ) {
data.append(uploaded_images[i].name, uploaded_images[i]);
}
fetch("/upload", {
method:"POST",
body:data
});
} else if (pageNum == 12) {
var data = new FormData();
for ( var i = 0; i < uploaded_GIFs.length; i++ ) {
data.append(uploaded_GIFs[i].name, uploaded_GIFs[i]);
}
fetch("/upload", {
method:"POST",
body:data
});
}
}
let saveSettingsButtons = document.querySelectorAll(".save-btn-div").forEach(button =>