当前位置:网站首页>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 ...
边栏推荐
- POJ 3207 Ikki&#39; s Story IV – Panda&#39; s Trick (2-SAT)
- leetcode先刷_Maximum Subarray
- Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
- Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
- Interpretation of Dagan paper
- Microservice architecture debate between radical technologists vs Project conservatives
- 腾讯安卓开发面试,android开发的基础知识
- Technology sharing | packet capturing analysis TCP protocol
- 技术分享 | 抓包分析 TCP 协议
- 小微企业难做账?智能代账小工具快用起来
猜你喜欢

beegfs高可用模式探讨

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

Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory

A5000 vgpu display mode switching

Standardized QCI characteristics

After solving 2961 user feedback, I made such a change

【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
腾讯T2大牛亲自讲解,跳槽薪资翻倍

22-07-05 七牛云存储图片、用户头像上传

腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
随机推荐
MySql必知必会学习
腾讯T3手把手教你,真的太香了
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
Recursive implementation of department tree
Tencent T3 teaches you hand in hand. It's really delicious
Standardized QCI characteristics
Oceanbase Community Edition OBD mode deployment mode stand-alone installation
系统与应用监控的思路和方法
From spark csc. csr_ Matrix generate adjacency matrix
Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
beegfs高可用模式探讨
Interpretation of Dagan paper
Analysis of rainwater connection
Qinglong panel white screen one key repair
What happened to the kernel after malloc() was transferred? Attached malloc () and free () implementation source
Alibaba数据源Druid可视化监控配置
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
范式的数据库具体解释
[Yann Lecun likes the red stone neural network made by minecraft]