Powtóreczka

This commit is contained in:
floriano committed 2026-09-30 17:28:53 +02:00
1 parent e80734527f
commit c1348ef991
648 files changed
+66782

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wysyłanie</title>
</head>
<body>
<h1>Wysyłanie tekstu i obrazka</h1>
<div style="width: 500px; height: 500px; overflow: hidden; border: 1px solid black;" id="obrazek"></div>
<div style="width: 500px; height: 500px; overflow: hidden; border: 1px solid black;" id="tekst"></div>
<input type="file" name="plik" id="plik">
<button id="wyslij">Wyślij</button>
<script>
const przycisk = document.getElementById("wyslij")
przycisk.onclick = function() {
const fd = new FormData()
fd.append("file", document.getElementById("plik").files[0])
const body = fd
const options = {
method: "POST",
body: body
}
fetch("/handleUpload", options)
.then(function(response) {
return response.json()
})
.then(function(data) {
console.log(data.typ)
if(data.typ == "obrazek") {
const obrazek = document.getElementById("obrazek")
obrazek.innerHTML = `<img src="${data.nazwa_pliku}">`
} else if(data.typ == "tekst") {
const tekst = document.getElementById("tekst")
tekst.innerText = data.tresc
}
})
.catch(function(err) {
console.error(err)
})
}
</script>
</body>
</html>