jquery mobile - Invoke native file browser using phonegap -


I have to implement the File Upload feature in my phonegap project. The user should be able to upload any type of file with phone memory or SD card. I designed the application screen using jQuery Mobile Framework. I tried the input type = "file", but it is not supported in Android 4.4. I also tried the PhoneGraph Camera API, but it only supports media files (I found some Cordova plugins) But using the Custom UI I want to open the original file browser to select the file & amp; It is the Android & amp; Both have to work in Is there any way to implement the iPhone platform in the same way?

I found the plugin to choose the Cordova file () would be useful for the Android platform, but I am unable to work it. Successful callback function is not triggered immediately after file selection (tested with Android 4.4.2). Please find your code below,

input type = "file" id = "fileinput" name = "fileinput" />

  $ ("# Fileinput"). Tie ('click', function () {console.log (file selected "select"); filechooser.open ({}, fileChooseSuccess, fileChooseFailed);}); Function file selection (data) {var filepath = data.filepath; Console.log ("File Path:" + File Path); } Select the function file (msg) {console.log (msg); }   

I was able to get your plugin, the file manager was working.

There are some things that However to be done though. You need to open the following with your editor

  • FileChooser.java
  • FileChooserActivity.java
  • FileListAdapter.java
  • FileListFragment .java
  • LocalStorageProvider.java

    and attach

      import your.package.name.R;  

    For each of those files

Here is the demo code I used:

 < Code> & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Hello World & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "cordova.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "https://code.jquery.com/jquery-2.1.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Document.addEventListener ("deviceready", function () {var success = function (data) {warning ("file selected:" + data.filepath);}; var error = function (msg) {console.log (msg); }; $ ('# Fileinput'). Click (function (e) {filechooser.open ({}, success, error);});}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "file" id = "fileinput" name = "file input" /> & Lt; / Body & gt; & Lt; / Html & gt;  

Also, be aware that the author was used to do KitKat 4.4.4. It can work with lower versions but it is uncertain.

Keep in mind that the HTML5 difference is the only difference between the window and this is the "internal storage" option.

Hope this will be helpful.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -