2014-01-27 62 views

回答

0

嗨,你可以使用phonegap FileTransfer方法。 FileTransfer對象允許您上傳或下載文件到服務器和從服務器下載文件。 如:

// !! Assumes variable fileURI contains a valid URI to a text file on the device 

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); 
console.log("upload error source " + error.source); 
console.log("upload error target " + error.target); 
} 

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

var params = {}; 
params.value1 = "test"; 
params.value2 = "param"; 

options.params = params; 

var ft = new FileTransfer(); 
ft.upload(fileURI, encodeURI("http://some.server.com/upload.php"), win, fail, options); 

我認爲這可以幫助你更多信息檢查link

+1

感謝您reply..In這個方法我在哪裏可以轉換爲WAV格式的.. – Ben10

+0

在IOS?或android ?,並檢查音頻的默認格式,我thnk的默認格式是.amr?我th轉換音頻文件爲wav你需要編寫本地插件。沒有默認的方法在phonegap @ SKM17 –

+0

在android之前上傳我轉換音頻爲wav格式 – Ben10