This article mainly introduces detailed information about how the applet obtains photo album photos. For more information about how the applet obtains photo album photos, see the following article, for more information, see
The applet obtains the photo album
Today, I met with the user profile picture setting function of the mini program and took notes.
First Upload gif:
Get image
2. index. js
// Index. js // Obtain the application instance var app = getApp () Page ({data: {tempFilePaths: ''}, onLoad: function () {}, chooseimage: function () {var _ this = this; wx. chooseImage ({count: 1, // Default 9 sizeType: ['original', 'compressed '], // you can specify whether the source image or the compressed image is used. Both have sourceType by default: ['alipay', 'Camera '], // you can specify whether the source is an album or a camera. Both have success: function (res) by default) {// return the local file path list of the selected image. the tempFilePath can be used as the src attribute of the img label to display the image _ this. setData ({tempFilePaths: res. tempFilePaths })}})}})
API description:
Wx. chooseImage ({success: function (res) {var tempFilePaths = res. tempFilePaths wx. uploadFile ({url: 'http: // example.weixin.qq.com/upload', // only for example. The non-real interface address is filePath: tempFilePaths [0], name: 'file', formData: {'user': 'test'}, success: function (res) {var data = res. data // do something }})}})
Thank you for reading this article. I hope it will help you. thank you for your support for this site!
The above is the detailed description of the photo album instance obtained by The applet. For more information, see other related articles in the first PHP community!