实现文件拖拽上传到服务器功能
一、步骤
1、客户端提交文件的请求方式必须是POST
2、发请求必须携带消息头:Content-Type:multipart/form-data
3、Content-Type:application/x-www-form-urlencode 客户端将本地文件在请求body部分以数据流方式传给服务器端
4、服务器端接收客户端传来的数据流,边接收边保存到服务器磁盘
二、获取拖拽文件信息
在全局安装
npm install multer
在客户端中创建新文件file.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>上传文件</title>
<style>
#div {
width: 600px;
height: 250px;
border: 2px solid black;
font-size: 40px;
font-weight: bold;
text-align: center;
line-height: 250px;
background-color:

最低0.47元/天 解锁文章
1089

被折叠的 条评论
为什么被折叠?



