Skip to content

Commit

Permalink
Update uploadfiles.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Qing9935 committed May 22, 2024
1 parent 8221dba commit 416ffd7
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions uploadfiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
padding: 10px;
border: 1px solid #ccc;
background-color: #f9f9f9;
white-space: pre-wrap; /* 保持换行格式 */
}
</style>
</head>
Expand All @@ -32,14 +33,26 @@ <h2>Upload a File</h2>
var file = fileInput.files[0];

if (file) {
// 构建自定义信息
var customMessage = 'You have selected a file with the following details:\n';
customMessage += 'File Name: ' + file.name + '\n';
customMessage += 'File Size: ' + (file.size / 1024).toFixed(2) + ' KB\n';
customMessage += 'File Type: ' + file.type;
var reader = new FileReader();

// 输出自定义信息到页面
output.textContent = customMessage;
reader.onload = function(e) {
var fileContent = e.target.result;
var customMessage = 'Upload successful!\n';//file with the following details:\n';
// customMessage += 'File Name: ' + file.name + '\n';
//customMessage += 'File Size: ' + (file.size / 1024).toFixed(2) + ' KB\n';
//customMessage += 'File Type: ' + file.type + '\n\n';
customMessage += 'RESULTS:\n' + fileContent;

// 输出自定义信息到页面
output.textContent = customMessage;
};

reader.onerror = function(e) {
output.textContent = 'Error reading file';
};

// 读取文件内容
reader.readAsText(file);
} else {
// 输出没有选择文件的信息
output.textContent = 'No file selected. Please choose a file to upload.';
Expand Down

0 comments on commit 416ffd7

Please sign in to comment.