0

音声の録音と音声ファイルのアップロードには、phogap 関数を使用しました。オーディオファイルは音楽フォルダに録音されて保存されており、以下の関数でファイルのパスと名前を取得します。

 function captureSuccess(mediaFiles) {
            var i, len;
            for (i = 0, len = mediaFiles.length; i < len; i += 1) {
                uploadFile(mediaFiles[i]);
            }
            alert('over');
        }
        function captureAudio() {
            navigator.device.capture.captureAudio(captureSuccess, captureError, { limit: 1, duration: 10 });

        }
        function uploadFile(mediaFile) {
            var ft = new FileTransfer(),
                path = mediaFile.fullPath,
                name = mediaFile.name;
            temp = path;  //Assigned path to GLOBAL VARIABLE
            temp1 = name;
            alert(temp);
        }   

作成した音声ファイルをアップロードする関数を呼び出します。

function uplod() {
            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.fileName = name;
            options.mimeType = "audio/mpeg";
            options.chunkedMode = false;

            var ft = new FileTransfer();
            ft.upload(temp,
                      "http:/URL/upload.php",
                      function (result) {
                          alert("success" + result.bytesSent + result.responseCode);
                          console.log('Upload success: ' + result.responseCode);
                          console.log(result.bytesSent + ' bytes sent');
                      },
                      function (error) {
                          console.log('Error uploading file ' + recordingPath + ': ' + error.code);
                      },
                      options);
        }

しかし、実行中にこれらのエラーが発生し、行き詰まりました。エラーは URL または PATH にありますか? ユニコード? ファイルのパスは次のようになります

C:/Users/AB/Music/captureAudio (4).mp3

 0x80070459 - JavaScript runtime error: No mapping for the Unicode character exists in the target multi-byte code page.

WinRT information: No mapping for the Unicode character exists in the target multi-byte code page.
4

1 に答える 1

0

Ajaxポストを使用Formdata()し、配列の形式でサーバーに使用することで答えを得ました。

于 2013-05-27T05:49:31.707 に答える