上传源代码版本
This commit is contained in:
48
test_upload.html
Normal file
48
test_upload.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>测试文件上传</title>
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>测试文件上传</h1>
|
||||
<form id="uploadForm">
|
||||
<input type="file" id="fileInput" multiple>
|
||||
<button type="submit">上传</button>
|
||||
</form>
|
||||
<div id="result"></div>
|
||||
|
||||
<script>
|
||||
$('#uploadForm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
const files = $('#fileInput')[0].files;
|
||||
const formData = new FormData();
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
formData.append('files', files[i]);
|
||||
}
|
||||
formData.append('type', 'shipping');
|
||||
|
||||
console.log('Files:', files);
|
||||
|
||||
$.ajax({
|
||||
url: 'http://172.232.21.79:5002/api/upload',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
console.log('Success:', response);
|
||||
$('#result').html('<p>上传成功: ' + JSON.stringify(response) + '</p>');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.log('Error:', xhr, status, error);
|
||||
$('#result').html('<p>上传失败: ' + error + '</p>');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user