Reputation: 698
I am trying to open file explorer in my ionic app when user clicks on button in Ionic ActionSheet
. This can be simply accomplished by putting <input type="file">
in HTML templates. But I am giving two options in actionsheet
$cordovaCamera
plugin to open camera but I have no idea how to open file explore.Here is my code for reference$ionicActionSheet.show({
buttons: [{ text: 'Open File Explorer //or <input type="file">' },
{ text: 'Open Camera' }],
buttonClicked: function(buttons) {
if(buttons == 0)
{
// what to do here ?
return true;
}
if(buttons == 1)
{
$scope.takeImage(Camera.PictureSourceType.CAMERA);
return true;
}}
})
Upvotes: 0
Views: 1391
Reputation: 698
I accomplished this by inserting <input type="file" id="fileupload" style="display:none">
and in my controller I used
if(buttons == 0)
{
// what to do here ?
document.getElementById('fileupload').click()
...
}
I hope this may help somebody.
Upvotes: 2
Reputation: 10720
Use cordova-plugin-file
plugin to handle file manager
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
Install the plugin using
cordova plugin add cordova-plugin-file
then use the provided functions under deviceready
event.
More info : https://github.com/apache/cordova-plugin-file
Upvotes: 0