Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
1f2d576
1
Parent(s):
89997b5
Update se_mes_im2.html
Browse files- se_mes_im2.html +12 -8
se_mes_im2.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
@@ -29,22 +29,26 @@
|
|
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 =>
|
|
|
|
|
|
|
|
|
|
|
38 |
.then(data => {
|
39 |
-
if (data.
|
40 |
document.getElementById('message').innerText = 'File uploaded successfully';
|
41 |
-
document.getElementById('imageUrl').innerHTML = `<a href="${data.
|
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>
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
|
|
29 |
|
30 |
fetch('https://api.green-api.com/waInstance1101952913/uploadFile/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92', {
|
31 |
method: 'POST',
|
|
|
|
|
|
|
32 |
body: formData
|
33 |
})
|
34 |
+
.then(response => {
|
35 |
+
if (!response.ok) {
|
36 |
+
return response.text().then(text => { throw new Error(text) });
|
37 |
+
}
|
38 |
+
return response.json();
|
39 |
+
})
|
40 |
.then(data => {
|
41 |
+
if (data.urlFile) {
|
42 |
document.getElementById('message').innerText = 'File uploaded successfully';
|
43 |
+
document.getElementById('imageUrl').innerHTML = `<a href="${data.urlFile}" target="_blank">Download Image</a>`;
|
44 |
} else {
|
45 |
document.getElementById('message').innerText = 'Failed to upload file';
|
46 |
}
|
47 |
})
|
48 |
.catch(error => {
|
49 |
+
console.error('Error:', error);
|
50 |
document.getElementById('message').innerText = 'Error: ' + error.message;
|
51 |
});
|
52 |
});
|
53 |
+
</script>
|
54 |
+
</body>
|