Micro-Letter Applet implementation of the recording after the upload file method details

Source: Internet
Author: User
Tags button type
This article describes the small program to implement the recording after the upload file method, everyone to the small program to implement the recording after uploading the file method do not know or to the small program to implement the recording after the file method of interest, then we will take a look at this article, good nonsense to get to the point!

Look directly at the code:

Startrecode:function () {var s = this;  Console.log ("Start");          Wx.startrecord ({success:function (res) {Console.log (res);          var tempfilepath = Res.tempfilepath;      S.setdata ({recodepath:tempfilepath, isrecode:true});          }, Fail:function (res) {Console.log ("fail");          Console.log (RES);  Recording failed});  }, Endrecode:function () {//end recording var s = this;  Console.log ("End");  Wx.stoprecord ();     S.setdata ({isrecode:false});  Wx.showtoast ();      SetTimeout (function () {var urls = app.globalData.urls + "/web/upvoice";      Console.log (S.data.recodepath);              Wx.uploadfile ({url:urls, Filepath:s.data.recodepath, Name: ' File ', header: { ' Content-type ': ' Multipart/form-data '}, Success:function (res) {var str = Res.dat              A              var data = Json.parse (str); if (data.states = = 1) {var ceditdata = S.data.ediTdata;                  ceditdata.recodeidentity = Data.identitys;              S.setdata ({editdata:ceditdata}); } else {Wx.showmodal ({title: ' Hint ', content:data                  . Message, Showcancel:false, Success:function (res) {}              });          } wx.hidetoast ();              }, Fail:function (res) {Console.log (res); Wx.showmodal ({title: ' Hint ', content: "Network request failed, make sure the network is OK", SHOWCANCEL:FA              LSE, Success:function (RES) {}});          Wx.hidetoast ();  }      }); },1000)}


page Code :

<button type= "PRIMARY" bindtouchstart= "Startrecode" bindtouchend= "Endrecode" class= "cxbtn" > Press and hold recording (optional) </ Button>

Summary : After recording to delay loading, recording after the generation of files will take some time, if not delayed loading may not be able to obtain the filename prompt: Uploadfile:localid is empty

Related recommendations:

Detailed POST request in Small program development

Small program implementation drop-down loading and pull-up refresh detailed explanation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.