上传图片
<h5>简要描述</h5>
<ul>
<li>上传图片接口
<pre><code>该接口仅应用于上传单图,用法请下载Demo示例参考</code></pre></li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://您的域名/index.php?m=api&c=v1.Api&a=upload_head_pic&_ajax=1</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>POST </li>
</ul>
<h5>参数</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
<th>示例</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">aid</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">int</td>
<td>文档ID</td>
<td>————</td>
</tr>
</tbody>
</table>
<h5>示例代码</h5>
<pre><code> wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], // 默认原图和压缩图
sourceType: ['album', 'camera'], // 默认指定来源是相册和相机
success: function(res) {
//注意:上传图片使用wx.uploadFile
wx.uploadFile({
url: 'https://demo.eyoucms.com/index.php?m=api&c=v1.Users&a=upload_head_pic&_ajax=1', //仅为示例,并非真实的接口地址
filePath: res.tempFilePaths[0],
name: 'file',
success: function(res) {
let result = typeof res.data === "object" ? res.data : JSON.parse(res.data);
if (result.code === 1) {
let img_url = result.data.img_url;//图片url
}
}
});
}
});</code></pre>
<h5>返回示例</h5>
<p>wx.uploadFile返回示例参考<a href="https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html" title="微信开发文档">微信开发文档</a></p>
<h5>备注</h5>
<ul>
<li>更多api接口持续完善中,欢迎踊跃参与补充与反馈</li>
</ul>
<p>感谢对易优小程序的支持,交流加QQ好友:1105415366 备注:gitee欢迎使用ShowDoc!</p>