上传文件限制大小
This commit is contained in:
@@ -39,6 +39,7 @@ Page({
|
||||
})
|
||||
},
|
||||
async upload(res) {
|
||||
|
||||
const result = await uploadPublicFile(res.tempFiles[0]?.tempFilePath)
|
||||
if (result.statusCode !== 200) {
|
||||
alertInfo("上传失败")
|
||||
@@ -55,6 +56,12 @@ Page({
|
||||
mediaType: ['image'], // 可以选择文件的类型,这里只允许上传文件
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
const file = res.tempFiles[0];
|
||||
if (file.size / 1024 / 1024 > 1) {
|
||||
alertInfo("文件不能大于1M")
|
||||
return;
|
||||
}
|
||||
// console.log('res', res)
|
||||
loadingFunc(async () => {
|
||||
await this.upload(res)
|
||||
})
|
||||
|
Reference in New Issue
Block a user