当前位置:网站首页>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 ...
边栏推荐
猜你喜欢
![[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer](/img/8c/afb90128e7a523bbee4c6c4166363f.png)
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer

《数字经济全景白皮书》保险数字化篇 重磅发布

Redisson bug analysis

Learn to explore - use pseudo elements to clear the high collapse caused by floating elements

2022年6月语音合成(TTS)和语音识别(ASR)论文月报

【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN

腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒

【计网】第三章 数据链路层(3)信道划分介质访问控制

手把手教你学会js的原型与原型链,猴子都能看懂的教程

Oceanbase Community Edition OBD mode deployment mode stand-alone installation
随机推荐
logstash高速入口
Transformer model (pytorch code explanation)
信息系统项目管理师---第八章 项目质量管理
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Test Li hi
Problems encountered in using RT thread component fish
Synchronization of data create trigger synchronization table for each site
企业精益管理体系介绍
范式的数据库具体解释
Tencent T3 teaches you hand in hand. It's really delicious
Leetcode brush first_ Maximum Subarray
Cesium 两点之间的直线距离
(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
学习打卡web
String length limit?
精彩编码 【进制转换】
Configuration and simple usage of the EXE backdoor generation tool quasar
Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
A5000 vgpu display mode switching