Supporto online

Parlare o chattare con i nostri esperti e ottenere le risposte alle vostre domande

Doesn't the default browser on Android 4.4 (Kit Kat) support input type=file field?

No it doesn't as the webview rendering engine before kitkat was Webkit, but its changed to Chromium now, however we created a workaround for this in Php where you need to change the existing from fields with some modifications. And put a condition to track the OS too.

For example if you have a form with the following fields that works on the web browsers perfectly fine.

You need to add some condition for OS and need to add the following code to the files, so that the web form will remain working and the android form will get generated using the same pattern and the form fields.

if (navigator.userAgent.toLowerCase().indexOf('android') != -1) { // for android var output='<form name="fileUpload" id="fileUpload" method="post" enctype="multipart/form-data">'+ '<input type="text" name="fname" value="<?php print ($_GET["fname"]!="")?$_GET["fname"]:"";?>" /><br>'+ '<input type="text" name="lname" value="<?php print ($_GET["lname"]!="")?$_GET["lname"]:"";?>" /><br>'+ '<input type="text" name="img" value="<?php print ($_GET["img"]!="")?$_GET["img"]:"";?>" /><br>'+ '<input type="button" onclick="uploadFn();" value="choose file"/><br>'+ '<input type="button" name="Submit" value="Submit" onclick="postData();" /></form>'; document.getElementById("formdisplay").innerHTML=output; } else { // for other browser var output1='<form name="fileUpload" id="fileUpload" method="post" enctype="multipart/form-data">'+ '<input type="text" name="fname" /><br&gt;'+ '<input type="text" name="lname" /><br>'+ '<input type="file" /><br>'+ '<input type="submit" name="Submit" value="Submit"/></form>';document.getElementById("formdisplay").innerHTML=output1; } </script> for the above code you need to write the postData and upload function. <script> function postData() { window.location="uploadServer:"+document.getElementsByName("img")[0].value; } function uploadFn() { window.location="fileupload:"+document.getElementsByName("fname")[0].value+"/"+document.getElementsByName("lname")[0].value; } </script>

Note: make sure if you add any new field to the web form than you need to get that added to the android form as well else the fro on the web and the device will be different.

Also, make sure that you've added the new field information to the upload function. Else the form will not be able to post the data using the form.
Avviare Tutorial