Browse Source

小程序限制能上传jpg、jpeg、png格式的图片

master
liujiangyong 2 years ago
parent
commit
4bbae7e63a
  1. 6
      weapp/package/inspectionInput/inspectionInput.js

6
weapp/package/inspectionInput/inspectionInput.js

@ -197,6 +197,12 @@ Page({
wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' }); wx.showToast({ title: '图片大于15M,不可上传', icon: 'none' });
return; return;
} }
const fileNameArr = res.tempFiles[i].tempFilePath.split('.');
const extension = res.tempFiles[i].tempFilePath.split('.')[fileNameArr.length - 1];
if (extension !== 'jpg' && extension !== 'png' && extension !== 'jpeg') {
wx.showToast({ title: '只能上传jpg、jpeg、png格式的图片', icon: 'none' });
return;
}
pics.push(imgs[i].tempFilePath) pics.push(imgs[i].tempFilePath)
} }
that.uploadimg({ that.uploadimg({

Loading…
Cancel
Save