在前后端分离的情况下如何保证服务端文件上传代码是否编写成功,这里用到一个简单的html页面,如下图:
代码的实现这里只需要替换的你要测试文件上传的API地址,源码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form action="填写自己要测试文件上传的API地址" method="POST" enctype="multipart/form-data">
file:<input type="file" name="file"/>
<input type="submit" value="uploadFile"/>
</form>
<p>multiFile</p>
<form method="POST" enctype="multipart/form-data" action="http://localhost:8100/api/files">
<p>file:<input type="file" name="file" /></p>
<p>file:<input type="file" name="file" /></p>
<p><input type="submit" value="upload" /></p>
</form>
</html>
最后你就可以脱离前端测试文件上传了