Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>sobe-img</title>
- </head>
- <body>
- <input type="file" id="imagem" multiple="multiple">
- <button id="btn-submit">Submit</button>
- <script>
- // Select your input type file and store it in a variable
- const inputFile = document.getElementById('imagem');
- const inputSubmit = document.getElementById('btn-submit');
- // let formData = new FormData();
- // let options = {
- // method: 'POST',
- // body: formData
- inputSubmit.addEventListener("click", (event) => {
- let formData = new FormData();
- let options = {
- method: 'POST',
- body: formData
- }
- formData.append('file', inputFile.files[0]);
- fetch('http://localhost:8000/upload_img', options)
- .then((response) => {
- return response.json();
- })
- .then((json) => {
- let input = `{"title": "kamzu","paths": "${json.output}"}`;
- let options = {
- method:'POST',
- headers: { "Content-Type" : "application/json" },
- body: input
- }
- fetch('http://localhost:8000/add_event', options)
- })
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement