Remember first it? Micro-channel does not provide a method of operating a file. Micro letter recently updated document, and I quickly ran update the blog, but also a lot of trouble ~ ~ ah, the good news came, micro-channel and finally out of the file-related operations API. And this is to force. I can not wait to try it again. As shown below:
Get to FileSystemManager, then call his readFile () or readFileSync (), the following parameters:
Supported encoding formats as follows:
He looked so much on the acid cool, ha ha ~.
We need to turn that picture is not a piece of cake do ~~ base64.
wx.chooseImage({ success: res => { wx.getFileSystemManager().readFile({ filePath: res.tempFilePaths [ 0 ], // select the corresponding return path image encoding: ' Base64 ' , // encoding format Success: RES => { // successful callback the console.log ( ' Data: Image / PNG; Base64 , ' + res.data) } }) //以下两行注释的是同步方法,不过我不太喜欢用。 //let base64 = wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], 'base64') //console.log(base64) } })
注意版本库要在1.9.9以后的版本才支持,注意版本控制。
原文:https://blog.csdn.net/qq_36875339/article/details/81086205