当前位置:网站首页>Wechat applet common collection
Wechat applet common collection
2022-07-06 20:05:00 【Infatuated Arvin】
Catalog
Wechat applet gets the size of uploaded pictures
Wechat applet base64 Bit size calculation

Wechat applet gets the size of uploaded pictures
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilesSize = res.tempFiles[0].size; // Get the size of the picture , Company B
const tempFilePaths = res.tempFilePaths;
console.log('size:', tempFilesSize)
if (tempFilesSize <= 2000000) { // Picture is less than or equal to 2M when You can get pictures
// code
} else { // Picture larger than 2M, Pop up a prompt box
wx.showToast({
title: ' Upload image cannot be larger than 2M!', // title
icon: 'none' // Icon none Don't use icons , For details, see the official documents
})
}
},
fail: function (res) {
wx.hideLoading()
}
});Wechat applet base64 Bit size calculation
/****base64 Bit size calculation **/
getImgSize(str) {
// obtain base64 Picture size , return KB Numbers
var str = base64url.replace('data:image/jpeg;base64,', '');// Here according to their own upload image format for the corresponding modification
var strLength = str.length;
var fileLength = parseInt(strLength - (strLength / 8) * 2);
// From byte to byte KB
var size = "";
size = (fileLength / 1024).toFixed(2);
return parseInt(size);
},Wechat applet subcontracting
"subPackages": [
{
"root": "A/",
"pages": [
"index/index",
"form/form"
]
},
{
"root": "B/",
"pages": [
"index/index",
"form/form"
]
}
]Conclusion
To be continued ...
边栏推荐
- Classic 100 questions of algorithm interview, the latest career planning of Android programmers
- 5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
- Guangzhou's first data security summit will open in Baiyun District
- mod_wsgi + pymssql通路SQL Server座
- 技术分享 | 抓包分析 TCP 协议
- 范式的数据库具体解释
- 从sparse.csc.csr_matrix生成邻接矩阵
- 枚举根据参数获取值
- 深度学习分类网络 -- ZFNet
- 2022年6月语音合成(TTS)和语音识别(ASR)论文月报
猜你喜欢
Tencent architects first, 2022 Android interview written examination summary

Cesium Click to draw a circle (dynamically draw a circle)

Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe

Selenium advanced operations

Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法

学习打卡web

腾讯T3大牛手把手教你,大厂内部资料

深度剖析原理,看完这一篇就够了

某东短信登录复活 安装部署教程

【计网】第三章 数据链路层(3)信道划分介质访问控制
随机推荐
Introduction to enterprise lean management system
In simple terms, interview surprise Edition
VMware virtual machine cannot open the kernel device "\.\global\vmx86"
Cesium 点击绘制圆形(动态绘制圆形)
String长度限制?
【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
青龙面板白屏一键修复
案例 ①|主机安全建设:3个层级,11大能力的最佳实践
Microservice architecture debate between radical technologists vs Project conservatives
MySql必知必会学习
Test Li hi
BUUCTF---Reverse---easyre
精彩编码 【进制转换】
Li Kou 101: symmetric binary tree
Node.js: express + MySQL实现注册登录,身份认证
POJ3617 Best Cow Line 馋
[Yann Lecun likes the red stone neural network made by minecraft]
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
Recursive implementation of department tree
腾讯架构师首发,2022Android面试笔试总结