当前位置:网站首页>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 ...
边栏推荐
- String length limit?
- DOM operation
- 从sparse.csc.csr_matrix生成邻接矩阵
- Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
- HDU 1026 Ignatius and the Princess I 迷宫范围内的搜索剪枝问题
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- 案例 ①|主机安全建设:3个层级,11大能力的最佳实践
- Learning and Exploration - Seamless rotation map
- 《数字经济全景白皮书》保险数字化篇 重磅发布
- Interpretation of Dagan paper
猜你喜欢

New generation garbage collector ZGC

A5000 vGPU显示模式切换
算法面试经典100题,Android程序员最新职业规划

枚举根据参数获取值
![[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)](/img/1e/b270a81c8457f1eae34f55c004a01a.png)
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)

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

Selenium advanced operations

5. 无线体内纳米网:十大“可行吗?”问题

学习打卡web

Monthly report of speech synthesis (TTS) and speech recognition (ASR) papers in June 2022
随机推荐
Oceanbase Community Edition OBD mode deployment mode stand-alone installation
Linear distance between two points of cesium
案例 ①|主机安全建设:3个层级,11大能力的最佳实践
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
Groovy基础语法整理
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
部门树递归实现
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
小微企业难做账?智能代账小工具快用起来
腾讯T3大牛手把手教你,大厂内部资料
Tencent Android interview must ask, 10 years of Android development experience
广州首个数据安全峰会将在白云区开幕
学习打卡web
Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?
Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
POJ 3207 Ikki&#39;s Story IV – Panda&#39;s Trick (2-SAT)
5. 无线体内纳米网:十大“可行吗?”问题
Analysis of rainwater connection
【GET-4】
夏志刚介绍