Skip to content

Cordova/Phonegap plugin that supplies a File Chooser

License

Notifications You must be signed in to change notification settings

jaydeepk3/MFileChooser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

About

Cordova/Phonegap plugin that supplies a File Chooser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.5%
  • JavaScript 1.5%