文档
测试

uploadFile

POST
api/v1/upload

接口描述

图片/视频上传

请求参数

参数名
类型
描述
必填
user_id
integer
用户id
必填
token
integer
用户token
必填
file
file
图片文件
必填

php

$client = new \GuzzleHttp\Client(); $response = $client->post( 'http://sns.shenruxiang.com/api/v1/upload', [ 'headers' => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => [ 'user_id' => 17, 'token' => 10, 'file' => 'est', ], ] ); $body = $response->getBody(); print_r(json_decode((string) $body));

js

const url = new URL( "http://sns.shenruxiang.com/api/v1/upload" ); let headers = { "Content-Type": "application/json", "Accept": "application/json", }; let body = { "user_id": 17, "token": 10, "file": "est" } fetch(url, { method: "POST", headers: headers, body: body }) .then(response => response.json()) .then(json => console.log(json));

返回值

{ "code": 0, "msg": "请求成功", "data": "\/storage\/2020-09-07\/a6685e585960fcac02de34cca617fdf1.jpg" }

bash

curl -X POST \ "http://sns.shenruxiang.com/api/v1/upload" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"user_id":17,"token":10,"file":"est"}'