DmitrMakeev
commited on
Update se_mes_im2.html
Browse files- se_mes_im2.html +49 -59
se_mes_im2.html
CHANGED
@@ -1,60 +1,50 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
// Обновляем src изображения, добавляя полученный URL сервера
|
49 |
-
var image = document.getElementById("cameraImage");
|
50 |
-
image.src = ownUrl + "/image?" + new Date().getTime();
|
51 |
-
})
|
52 |
-
.catch(error => {
|
53 |
-
document.getElementById('message').innerText = 'Error: ' + error.message;
|
54 |
-
});
|
55 |
-
});
|
56 |
-
});
|
57 |
});
|
58 |
-
|
59 |
-
</
|
60 |
-
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Upload Image</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>Upload Image</h1>
|
10 |
+
<form id="uploadForm">
|
11 |
+
<input type="file" id="fileInput" accept="image/*">
|
12 |
+
<button type="submit">Upload</button>
|
13 |
+
</form>
|
14 |
+
<div id="message"></div>
|
15 |
+
<div id="imageUrl"></div>
|
16 |
+
|
17 |
+
<script>
|
18 |
+
document.getElementById('uploadForm').addEventListener('submit', function(event) {
|
19 |
+
event.preventDefault();
|
20 |
+
const fileInput = document.getElementById('fileInput');
|
21 |
+
const file = fileInput.files[0];
|
22 |
+
if (!file) {
|
23 |
+
document.getElementById('message').innerText = 'No file selected';
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
const formData = new FormData();
|
28 |
+
formData.append('file', file);
|
29 |
+
|
30 |
+
fetch('https://api.green-api.com/waInstance1101952913/uploadFile/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92', {
|
31 |
+
method: 'POST',
|
32 |
+
headers: {
|
33 |
+
'Content-Type': 'image/jpeg'
|
34 |
+
},
|
35 |
+
body: formData
|
36 |
+
})
|
37 |
+
.then(response => response.json())
|
38 |
+
.then(data => {
|
39 |
+
if (data.url) {
|
40 |
+
document.getElementById('message').innerText = 'File uploaded successfully';
|
41 |
+
document.getElementById('imageUrl').innerHTML = `<a href="${data.url}" target="_blank">Download Image</a>`;
|
42 |
+
} else {
|
43 |
+
document.getElementById('message').innerText = 'Failed to upload file';
|
44 |
+
}
|
45 |
+
})
|
46 |
+
.catch(error => {
|
47 |
+
document.getElementById('message').innerText = 'Error: ' + error.message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
});
|
49 |
+
});
|
50 |
+
</script>
|
|