为了账号安全,请及时绑定邮箱和手机立即绑定

图是语音转成base64的,我在上传base64,date:{files:}怎么写?

图是语音转成base64的,我在上传base64,date:{files:}怎么写?

慕村225694 2018-10-18 14:09:12
图是语音转成base64的,我在上传base64,date:{files:}怎么写?参数是files;/**                  * 录音语音文件转base64字符串                  * @param {Object} path                  */                 function Audio2dataURL(path) {                     plus.io.resolveLocalFileSystemURL(path, function(entry) {                         entry.file(function(file) {                                                     var reader = new plus.io.FileReader();                             reader.onloadend = function(e) {                                                             console.log(e.target.result);                                 alert(e.target.result)                             };                             reader.readAsDataURL(file);                         }, function(e) {                             mui.toast("读写出现异常: " + e.message);                         })                     })data: {                            files:                         },
查看完整描述

1 回答

?
开心每一天1111

TA贡献1836条经验 获得超13个赞

参数是 files,它的值是 e.target.result。但是我不知道你的如何存储,省事点就是一个全局变量保存起来。就如你之前写的这写些全局变量。

https://img1.sycdn.imooc.com//5bde890200017ec001780107.jpg

例子:

var baseResult = null;


function Audio2dataURL(path) {

    plus.io.resolveLocalFileSystemURL(path, function(entry) {

        entry.file(function(file) {

            var reader = new plus.io.FileReader();

            reader.onloadend = function(e) {

                baseResult = e.target.result); // 赋给全局变量

            };

    

            reader.readAsDataURL(file);

        }, function(e) {

            mui.toast("读写出现异常: " + e.message);

        })

    })

    

    

 // 然后


data: {

    files: baseResult

},

....


查看完整回答
反对 回复 2018-11-04
  • 1 回答
  • 0 关注
  • 1038 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号