在Windows RT上使用phonegap上传mp3文件[Unicode Mapping错误]

时间:2013-05-25 07:10:21

标签: javascript jquery windows-8 visual-studio-2012 cordova

我使用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? Unicode?和文件的路径是这样的

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.

1 个答案:

答案 0 :(得分:0)

我通过使用Ajax帖子和使用Formdata()来获取答案,通过以数组的形式获取服务器。