chooseFile() {
this.fileChooser.open().then(file => {
this.filePath.resolveNativePath(file).then(resolvedFilePath => {
this.fileOpener.open(resolvedFilePath, 'audio/mpeg3').then(file => {
alert("File Selected!");
}
).catch(err => {
alert(JSON.stringify(err));
});
}).catch(err => {
alert(JSON.stringify(err));
});
}).catch(err => {
alert(JSON.stringify(err));
});
}
I am new to ionic, I am working on a simple audio upload project.
I have a simple file chooser, I need to get the file location of the selected file in order to upload it.
upload() {
let options: FileUploadOptions = {
fileKey: 'file',
fileName: 'music',
mimeType: 'audio/mp3',
headers: {}
}
const fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.upload(URL ,'http://websitename.com/uploads.php', options)
.then((data) => {
// success
alert('Congratulations !! File has been uploaded ');
}, (err) => {
// error
alert(JSON.stringify(err));
})
}
I am in dead end. It would be great if u guys could help.