Upload image resource interface

API call address

{域名地址}/api/attachment/upload

illustrate:{域名地址}You need to replace it with your domain address, such as/api/attachment/upload

Calling methods

POST form-data

Request parameters

Field name type Required illustrate
category_id int no Image resource category ID
id int no Image resource ID, if it is a replacement image, it is required
file File yes File resources to upload

Return parameters

Field name type illustrate
code int Error code
msg string Error Cause Description
data object Results content

Data parameters

Field name type illustrate
id int Resource ID
file_name string file name
file_location string File storage path
file_size int File size
file_md5 string File MD5
width int Image width
height int Image height
category_id int Resource Category ID
is_image int Is it a picture? 1 is a picture? 0 is not
logo string Original image
thumb string Thumbnail
created_time int Create a timestamp
updated_time int Update time stamp
status int Display status

Request data example

parameter value
category_id 1
file File Resource

Return to the data example

{
    "code": 0,
    "data": {
        "id": 213,
        "created_time": 1662734332,
        "updated_time": 1662734332,
        "file_name": "AnqiCMS",
        "file_location": "uploads/202209/09/5632dd13c746a365.webp",
        "file_size": 9348,
        "file_md5": "4fae2c295632dd13c746a3653227f93a",
        "width": 160,
        "height": 160,
        "category_id": 0,
        "is_image": 1,
        "status": 1,
        "logo": "/uploads/202209/09/5632dd13c746a365.webp",
        "thumb": "/uploads/202209/09/thumb_5632dd13c746a365.webp"
    },
    "msg": ""
}

Error code

Error code illustrate
0 OK
-1 Error, the cause of the error is pointed out in msg
1001 Not logged in
1002 Unauthorized
200 API request OK