Skip to content

Instantly share code, notes, and snippets.

@marcobehlerjetbrains
Created March 23, 2022 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marcobehlerjetbrains/ccd1df86fdd0ae5193aa143c83e30e5d to your computer and use it in GitHub Desktop.
Save marcobehlerjetbrains/ccd1df86fdd0ae5193aa143c83e30e5d to your computer and use it in GitHub Desktop.
Spring Boot REF3 - upload.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2>Photo Upload</h2>
<input id="fileupload" type="file" name="fileupload" />
<button id="upload-button" onclick="uploadFile()"> Upload </button>
<script>
async function uploadFile() {
let formData = new FormData();
formData.append("data", fileupload.files[0]);
await fetch('http://localhost:8080/photoz', {
method: "POST",
body: formData
}).then(result => result.text())
.then(text => alert(text));
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment