通过 $ionicActionSheet.show() 在 ionic 中打开文件资源管理器



当用户单击Ionic ActionSheet中的按钮时,我正在尝试在我的 ionic 应用程序中打开文件资源管理器。这可以通过将<input type="file">放入 HTML 模板中简单地完成。但我在行动表中给出了两个选项

  1. 打开相机
  2. 打开文件资源管理器我使用$cordovaCamera插件打开相机,但我不知道如何打开文件探索。这是我的代码供参考

$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;
     }}
     })

我通过插入<input type="file" id="fileupload" style="display:none">来实现这一点,在我的控制器中我使用

 if(buttons == 0)
   {
    // what to do here ?
    document.getElementById('fileupload').click()
         ...
    }

我希望这可能会对某人有所帮助。

使用cordova-plugin-file插件处理文件管理器

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/

使用 安装插件

cordova plugin add cordova-plugin-file

然后使用"deviceready事件"下提供的函数。

More info : https://github.com/apache/cordova-plugin-file

相关内容

最新更新