我正在开发的应用程序与电话差距和jQuery移动。我想从播放列表中选择音频文件,然后将其上传到服务器。我有谷歌它,但没有链接,显示选择音频文件,然后上传到服务器上,我不想录制任何音频。我只想上传音频(即在我的音乐文件夹或播放列表)到服务器上。请帮帮我。
发布于 2013-12-06 15:07:31
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获取的
https://stackoverflow.com/questions/20417500
复制相似问题