multipart/form-data请求与文件上传的细节

<!DOCTYPE html>
<html>
<head lang="en">
 <meta charset="UTF-8">
 <title></title>
 <script src="js/jquery.min.js"></script>
</head>
<body>
<form id= "uploadForm" action= "http://192.168.12.50:8080/file/upload" method= "post" enctype ="multipart/form-data">
<!--<p >指定文件名: <input type ="text" name="filename" /></p>-->
<p >上传文件: <input type ="file" name="file" /></p>
<p >关键字1: <input type ="text" name="areaCode" /></p>
<p >关键字1: <input type ="text" name="sessionId" /></p>
<input type ="submit" value="上传"/>
</form>
</body>
</html>
<script>
var dataReq={areaCode:"globalservice",file:"u=384764150,406696308&fm=27&gp=0.jpg",sessionId:"FF4F1F829F43D6E59AF3A1E67CA6B8B9"};
$.ajax({
url : "http://192.168.12.50:8080/file/upload",
type : "POST",
data : dataReq,
success : function(data) {
$( '#serverResponse').html(data);
},
error : function(data) {
$( '#serverResponse').html(data.status + " : " + data.statusText + " : " + data.responseText);
}
});
</script>
原文地址:https://www.cnblogs.com/cx709452428/p/7873258.html