transfer a file from library to external server
I can not transfer a video file from the smartphone library to my server.
I'm using this code, but I can not pass the FILE_URI to transfer function.
code
var cameraSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles);
// do something interesting with the file
}
};
// capture error callback
var cameraError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
// start video capture
navigator.camera.getPicture(cameraSuccess, cameraError, {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
mediaType: navigator.camera.MediaType.VIDEO });
// Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
Appery("nomeVideo").text(name);
Code: Select all
ft.onprogress = function(result){
var percent = result.loaded / result.total * 100;
percent = Math.round(percent);
Appery('progressbar').text('Upload: ' + percent + '%');
};
ft.upload(path,
"http://www.xxx.com/uploadVideo/index.php",
function(result) {
alert('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function(error) {
alert('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
} /code
Can you help me?