Update index.html
Browse files- index.html +13 -5
index.html
CHANGED
|
@@ -4,6 +4,14 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>File Upload</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</head>
|
| 8 |
<body>
|
| 9 |
<input type="file" id="fileInput">
|
|
@@ -21,7 +29,7 @@
|
|
| 21 |
const formData = new FormData();
|
| 22 |
formData.append('file', file);
|
| 23 |
|
| 24 |
-
|
| 25 |
for (let [key, value] of formData.entries()) {
|
| 26 |
console.log(`${key}:`, value);
|
| 27 |
}
|
|
@@ -34,10 +42,10 @@
|
|
| 34 |
|
| 35 |
const result = await response.json(); // 假设服务器返回 JSON 格式的数据
|
| 36 |
if (response.ok) {
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
} catch (error) {
|
| 42 |
console.error('Error uploading file:', error);
|
| 43 |
alert('Error uploading file.');
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>File Upload</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
background-image: url('https://openai-75050.gzc.vod.tencent-cloud.com/openaiassets_b2edbcb71bed2e127d071803cc655cbf_2579861726125066950.jpg');
|
| 10 |
+
background-size: cover;
|
| 11 |
+
background-repeat: no-repeat;
|
| 12 |
+
background-attachment: fixed;
|
| 13 |
+
}
|
| 14 |
+
</style>
|
| 15 |
</head>
|
| 16 |
<body>
|
| 17 |
<input type="file" id="fileInput">
|
|
|
|
| 29 |
const formData = new FormData();
|
| 30 |
formData.append('file', file);
|
| 31 |
|
| 32 |
+
// 输出 FormData 内容
|
| 33 |
for (let [key, value] of formData.entries()) {
|
| 34 |
console.log(`${key}:`, value);
|
| 35 |
}
|
|
|
|
| 42 |
|
| 43 |
const result = await response.json(); // 假设服务器返回 JSON 格式的数据
|
| 44 |
if (response.ok) {
|
| 45 |
+
alert('File uploaded successfully! Server response: ' + JSON.stringify(result));
|
| 46 |
+
} else {
|
| 47 |
+
alert('File upload failed. Server response: ' + JSON.stringify(result));
|
| 48 |
+
}
|
| 49 |
} catch (error) {
|
| 50 |
console.error('Error uploading file:', error);
|
| 51 |
alert('Error uploading file.');
|