当前位置:网站首页>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 ...
边栏推荐
- 腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
- Color is converted to tristimulus value (r/g/b) (dry stock)
- Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
- Problems encountered in using RT thread component fish
- mod_wsgi + pymssql通路SQL Server座
- 企业精益管理体系介绍
- Node. Js: express + MySQL realizes registration, login and identity authentication
- Configuration and simple usage of the EXE backdoor generation tool quasar
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
- Interpretation of Dagan paper
猜你喜欢

Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech

Li Kou 101: symmetric binary tree

Crawler (14) - scrape redis distributed crawler (1) | detailed explanation

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

系统与应用监控的思路和方法

HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅

理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)

信息系统项目管理师---第八章 项目质量管理

A5000 vGPU显示模式切换

【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
随机推荐
腾讯架构师首发,2022Android面试笔试总结
Blue Bridge Cup microbial proliferation C language
Alibaba data source Druid visual monitoring configuration
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Technology sharing | packet capturing analysis TCP protocol
AddressSanitizer 技术初体验
Wonderful coding [hexadecimal conversion]
Oceanbase Community Edition OBD mode deployment mode stand-alone installation
Learning and Exploration - function anti shake
Database specific interpretation of paradigm
MySql必知必会学习
[play with Linux] [docker] MySQL installation and configuration
语音识别(ASR)论文优选:全球最大的中英混合开源数据TALCS: An Open-Source Mandarin-English Code-Switching Corpus and a Speech
Tencent architects first, 2022 Android interview written examination summary
Transformer model (pytorch code explanation)
5. 無線體內納米網:十大“可行嗎?”問題
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
Learning and Exploration - Seamless rotation map
rt-thread i2c 使用教程