博客 API

博客网站的API接口文档


上传头像

简要描述:

  • 头像上传接口

请求 URL:

  • /my/update

请求方式:

  • POST

请求头:

Authorization :Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwidXNlcm5hbWUiOiJhZG1pbjEyMyIsInBhc3N3b3JkIjoiIiwibmlja19uYW1lIjpudWxsLCJlbWFpbCI6IjEyMzQ1NkBxcS5jb20iLCJwaWNfbmFtZSI6IiIsInJlZ19kYXRlIjoiMjAyMi0xMS0yMCAxMzo1NDo1NCIsInN0YXR1cyI6MCwiaWF0IjoxNjY4OTI3MDA5LCJleHAiOjE2NzI1MjM0MDl9.nB9ywvSdTzEYuuNlqMw_8YudjUmGesPfSRaRi-NKP2x

代码示例:

$('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);
     }
   })
})

返回示例:

{
    "status": 0,
    "msg": "头像上传成功!"
}

返回参数说明:

参数名 类型 说明
status int (0:请求成功)(1: 请求失败)
msg string 请求结果的描述消息

页面列表

ITEM_HTML