上传头像
<p>简要描述:</p>
<ul>
<li>头像上传接口</li>
</ul>
<p>请求 URL:</p>
<ul>
<li><code>/my/update</code></li>
</ul>
<p>请求方式:</p>
<ul>
<li><code>POST</code></li>
</ul>
<p>请求头:</p>
<pre><code class="language-java">Authorization :Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwidXNlcm5hbWUiOiJhZG1pbjEyMyIsInBhc3N3b3JkIjoiIiwibmlja19uYW1lIjpudWxsLCJlbWFpbCI6IjEyMzQ1NkBxcS5jb20iLCJwaWNfbmFtZSI6IiIsInJlZ19kYXRlIjoiMjAyMi0xMS0yMCAxMzo1NDo1NCIsInN0YXR1cyI6MCwiaWF0IjoxNjY4OTI3MDA5LCJleHAiOjE2NzI1MjM0MDl9.nB9ywvSdTzEYuuNlqMw_8YudjUmGesPfSRaRi-NKP2x</code></pre>
<p>代码示例:</p>
<pre><code class="language-javascript">$('input').on('change', function () {
var files = $(this)[0].files[0]
var fd = new FormData()
fd.append('zyd', files)
$.ajax({
url: 'http://127.0.0.1/my/update',
method: 'post',
headers: {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwidXNlcm5hbWUiOiJhZG1pbjEyMyIsInBhc3N3b3JkIjoiIiwibmlja19uYW1lIjpudWxsLCJlbWFpbCI6IjEyMzQ1NkBxcS5jb20iLCJwaWNfbmFtZSI6IiIsInJlZ19kYXRlIjoiMjAyMi0xMS0yMCAxMzo1NDo1NCIsInN0YXR1cyI6MCwiaWF0IjoxNjY4OTI3MDA5LCJleHAiOjE2NzI1MjM0MDl9.nB9ywvSdTzEYuuNlqMw_8YudjUmGesPfSRaRi-NKdfd2g'
},
data: fd,
contentType: false,
processData: false,
success: function (res) {
console.log(res);
}
})
})</code></pre>
<p>返回示例:</p>
<pre><code class="language-json">{
"status": 0,
"msg": "头像上传成功!"
}</code></pre>
<p>返回参数说明:</p>
<table>
<thead>
<tr>
<th style="text-align: center;">参数名</th>
<th style="text-align: center;">类型</th>
<th style="text-align: center;">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">status</td>
<td style="text-align: center;">int</td>
<td style="text-align: center;">(0:请求成功)(1: 请求失败)</td>
</tr>
<tr>
<td style="text-align: center;">msg</td>
<td style="text-align: center;">string</td>
<td style="text-align: center;">请求结果的描述消息</td>
</tr>
</tbody>
</table>