-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai.svgupgenasciifu.html
55 lines (45 loc) · 1.46 KB
/
ai.svgupgenasciifu.html
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
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<body>
<h2>Upload Image</h2>
<p>Click on the "Choose File" button to upload a file:</p>
<input type="file" id="myFile" name="filename" accept="image/*">
<button type="button" onclick="uploadFile()">Upload</button>
<script>
function uploadFile() {
var file = document.getElementById('myFile').files[0];
// Check file size (must be less than 10MB)
if (file.size > 10485760) {
alert('File size must be less than 10MB.');
return;
}
// Check image dimensions (must be less than 24000px square)
var img = new Image();
img.onload = function() {
if (this.width > 24000 || this.height > 24000) {
alert('Image dimensions must be less than 24000px square.');
return;
}
// If all checks pass, upload the file
var formData = new FormData();
formData.append('file', file);
fetch('/upload', {
method: 'POST',
body: formData
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
}).then(data => {
console.log('File uploaded successfully:', data);
}).catch(error => {
console.error('There was a problem with the file upload:', error);
});
};
img.src = URL.createObjectURL(file);
}
</script>
</body>
</html>
<!-- client-side HTML page for the file upload -->