问题
I have a small phonegap app for android.
One button launches a website I built with jquery mobile 1.3.
I am opening the page using:
websiteRef=window.open('https://'+webstage+'.mysite.org/mobile?language_id=2', '_blank', 'location=no' );
The website works fine. But when I hit one page that allows for uploading a file using the following markup:
<input type="file" name="upload" value="file" data-inline="true" style="min-width:100px;"/>
It does not work. It does not even show a file selection dialog (gallery, etc.). The button is completely without function and reaction.
Opening the exact same page using the android internet browser works fine. At the exact same page I can choose e. g. from Gallery and other file selection methods and the upload works.
Since this is an external website, all the references to phonegap PLUGINs like Android File UPloader appear to be of no help for me.
回答1:
input type file is not supported by androids webview (it works on iOS though). if you want to browse your gallery, you need to use the camera api to retrieve the URI and then, if you want to upload it somewhere > use the file api.
回答2:
for media elements (like audio mp3), use cordova-pluin-mediapicker
window.plugins.mediapicker.getAudio(success,error,false,false," ");
function success(data)
{
console.log(JSON.stringify(data));
}
function error(e)
{
console.log(e);
}
more info here
https://github.com/an-rahulpandey/cordova-plugin-mediapicker
来源:https://stackoverflow.com/questions/17760334/phonegap-2-9-android-inappbrowser-input-type-file-not-working