You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<title>视频上传和下载</title> |
|
</head> |
|
<body> |
|
|
|
|
|
<div id="app2"> |
|
<input type="file" ref="fileInput" @change="handleFileChange"> |
|
<button @click="uploadFile">上传</button> |
|
</div> |
|
|
|
|
|
<!-- 开发环境版本,包含了有帮助的命令行警告 --> |
|
<script src="../../plugins/vue/vue.js"></script> |
|
<!-- 引入组件库 --> |
|
<script src="../../plugins/element-ui/index.js"></script> |
|
<!-- 引入axios --> |
|
<script src="../../plugins/axios/axios.min.js"></script> |
|
<script> |
|
new Vue({ |
|
el: '#app2', |
|
data: { |
|
selectedFile:'' |
|
}, |
|
methods: { |
|
handleFileChange(event) { |
|
this.selectedFile = event.target.files[0]; |
|
}, |
|
uploadFile() { |
|
const formData = new FormData(); |
|
formData.append('file', this.selectedFile); |
|
|
|
// 发送文件上传请求 |
|
axios.post('/video/upload', formData) |
|
.then(response => { |
|
// 处理上传成功的响应 |
|
console.log(response.data); |
|
}) |
|
.catch(error => { |
|
// 处理上传失败的错误 |
|
console.error(error); |
|
}); |
|
} |
|
} |
|
}); |
|
|
|
|
|
</script> |
|
|
|
|
|
</body> |
|
</html>
|
|
|