<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="file" name="upload" id="upload" value="" />
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
let formData = new FormData()
formData.append('file', $('#upload')[0].files[0])
$.ajax({
url: 'http://lr.offdin.com/v1/upload_photo',
type: 'post',
data: formData,
contentType: false, // 发送数据到服务器时所使用的内容类型。默认是:"application/x-www-form-urlencoded"。 不设置内容类型
processData: false, // 布尔值,规定通过请求发送的数据是否转换为查询字符串。默认是 true。 不处理数据
success: function (res) {
console.log(res)
}
})
</script>
</body>
</html>
网友评论