In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor would like to share with you the relevant knowledge points about how Mini Program takes pictures from photo albums and uploads them and uses the camera to take pictures. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge. So share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1.index.wxml
1 2 get picture 3 2.index.js
1 / / index.js2 / / get application instance 3 var app = getApp () 4 Page ({5 data: {6 tempFilePaths:'7}, 8 onLoad: function () {9}, 10 chooseimage: function () {11 var _ this = this) 12 wx.chooseImage ({13 count: 1, / default 914 sizeType: ['original',' compressed'], / / you can specify whether it is the original image or a compressed image. By default, both have 15 sourceType: ['album',' camera'], / / you can specify whether the source is a photo album or a camera, and both have 16 success by default: function (res) {17 / returns the local file path list of the selected photo TempFilePath can be used as the src attribute of the img tag to display the picture 18 _ this.setData ({19 tempFilePaths:res.tempFilePaths20}) 21} 22}) 23} 24}) here we talk about sourcetype. The default is to get photos from albums and take pictures with a camera. Like the interface in which Wechat now selects pictures, the first frame is to take photos, followed by album photos.
Note here: what is returned is the local path of the picture. If you need to upload the picture to the server, you need to use another API.
Sample code:
1 wx.chooseImage ({2 success: function (res) {3 var tempFilePaths = res.tempFilePaths4 wx.uploadFile ({5 url: 'http://example.weixin.qq.com/upload', / / for example only) Non-real interface address 6 filePath: tempFilePaths [0], 7 name: 'file',8 formData: {9' user': 'test'10}, 11 success: function (res) {12 var data = res.data13 / / do something14} 15}) 16} 17}) these are all the contents of this article entitled "how Mini Program gets pictures from photo albums and uploads them and uses the camera to take pictures". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.