首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >phonegap选择音频文件并上传到服务器

问phonegap选择音频文件并上传到服务器
EN

Stack Overflow用户
提问于 2013-12-06 14:29:58
回答 1查看 863关注 0票数 0

我正在开发的应用程序与电话差距和jQuery移动。我想从播放列表中选择音频文件,然后将其上传到服务器。我有谷歌它,但没有链接,显示选择音频文件,然后上传到服务器上,我不想录制任何音频。我只想上传音频(即在我的音乐文件夹或播放列表)到服务器上。请帮帮我。

EN

回答 1

Stack Overflow用户

发布于 2013-12-06 15:07:31

代码语言:javascript
复制
function uploadVoice(fileName, dirName, fileMime, uploadURL) {

var win = function (r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
};

var fail = function(error) {
    alert("An error has occurred: Code = " = error.code);
};

// file system fail
var fsFail = function(error) {
    alert("failed with error code: " + error.code);

};

var dirFail = function(error) {
    alert("Directory error code: " + error.code);

};

var fileURI;

var gotFileSystem = function (fileSystem) {
    fileSystem.root.getDirectory(dirName, {
        create: false
    }, function (dataDir) {

        fileURI = dataDir.fullPath;
        fileURI = fileURI + '/' + fileName;

        var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
        options.mimeType = fileMime;

        var params = new Object();
        params.value1 = "test";
        params.value2 = "param";

        options.params = params;

        var ft = new FileTransfer();
        ft.upload(fileURI, uploadURL, win, fail, options);

    }, dirFail);

};

// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, fsFail);

}

这是从链接Phonegap - How can I upload an audio file after recording with Phonegap's media.startRecord获取的

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20417500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档