|
录音玩之后怎么把这个录音文件传给后端,后端接到的文件一直是空,但是id能接到。。。求解惑,代码如下- //captureAudio方法成功执行后回调函数
- function captureSuccess(mediaFiles) {
- var i, len;
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- //业务逻辑
- alert(mediaFiles[i].fullPath + "****" +mediaFiles[i].name);
- var f = new FormData();
- f.append("audioUrl", mediaFiles[i]);
- f.append("id", 1);
- var xhr = new XMLHttpRequest();
- xhr.open('post', 'http://10.220.115.47:8089/phone/member/personalCenter/uploadVoice.json', true);
- xhr.send(f);
- xhr.onreadystatechange = function() {
- alert(xhr.responseText);
- }
- }
- }
-
- //captureAudio方法执行失败后回调函数
- function captureError(error) {
- var msg = 'capture 发生错误: ' + error.code;
- navigator.notification.alert(msg, null, 'Uh oh!');
- }
-
- function captureAudio() {
- // limit 录制的音频数
- navigator.device.capture.captureAudio(captureSuccess, captureError, {limit: 1});
- }
复制代码 |
|