1.0.7 • Published 8 years ago

cordova-plugin-dotneet-mfilechooser v1.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

MFileChooser

Cordova/Phonegap plugin that supplies a File Chooser for Android 4+. The File Chooser does not require installation external file manager

alt text | alt text

Limitation

Currently, this plugin only support an image format.

Adding the Plugin to your project

Plugin has been successfully tested on Android 4+ device with Cordova 3.

To install the plugin

cordova plugin add --save cordova-plugin-dotneet-mfilechooser

Using the plugin

The plugin creates the object window.plugins.mfilechooser. To use, call the open() method:

Simple using

   window.plugins.mfilechooser.open([], function (uri) {
      
      alert(uri);
      
    }, function (error) {
      
        alert(error);
    
    });

Filtering by extension

   window.plugins.mfilechooser.open(['.doc', '.xls', '.ppt'], function (uri) {
      
      alert(uri);
      
    }, function (error) {
      
        alert(error);
    
    });

File Upload

Below is the file upload example by ES2016. (It depend on cordova-plugin-file-transfer)

window.plugins.mfilechooser.open(['.jpg', '.jpeg', '.png'], (url) => {
  window.resolveLocalFileSystemURL(url, (entry) => {
    const ft = new FileTransfer();
    const success = () => console.log('success')
    const fail = () => console.log('fail')
    ft.upload(entry.toURL(), encodeURI('http://example.com/upload.php'), success, fail, {})
  })
})

Release notes

September 16, 2014 Initial release

Contribution

This plugin based on follow repository: