File and photo uploads
<!-- any image from gallery or camera -->
<input type="file" accept="image/*">
<!-- go straight to the rear camera -->
<input type="file" accept="image/*" capture="environment">
<!-- documents -->
<input type="file" accept=".pdf,.doc,.docx">
Unlike a browser, a WebView does nothing when a file input is tapped unless the app shell implements a file chooser. Good builders do; if tapping the button does nothing, the shell doesn't support it.
Permissions
| Feature | Web API | Android permission |
|---|---|---|
| Camera photo via file input | <input capture> | Camera (asked by the shell) |
| Live camera / QR scanning | getUserMedia({ video: true }) | Camera |
| Location | navigator.geolocation | Location |
| Voice recording | getUserMedia({ audio: true }) | Microphone |
On Android 6.0 and later, permissions are requested at the moment they're needed. Ask in context — show a "Find my nearest store" button rather than requesting location on launch — and handle refusal gracefully.
Secure context
Camera, microphone and location require a secure context. Live sites must use https://. Bundled files are treated as a local origin; test that each feature works in your built app before you rely on it.
Write fallbacks
if (!('geolocation' in navigator)) showManualPostcodeField();
navigator.geolocation.getCurrentPosition(ok, err => {
if (err.code === err.PERMISSION_DENIED) showManualPostcodeField();
}, { timeout: 10000 });
Privacy and Google Play
If you publish on Google Play, declare what you collect in the Data safety form and link a privacy policy. Only request permissions your app really uses — unused permissions attract review questions and scare users.
Resize photos before uploading
Phone cameras produce 3–12 MB images. Shrinking them in the page before upload makes forms faster and cheaper on mobile data:
async function shrink(file, max = 1600) {
const img = await createImageBitmap(file);
const s = Math.min(1, max / Math.max(img.width, img.height));
const c = Object.assign(document.createElement('canvas'),
{ width: img.width * s, height: img.height * s });
c.getContext('2d').drawImage(img, 0, 0, c.width, c.height);
return new Promise(r => c.toBlob(r, 'image/jpeg', 0.85));
}
QR and barcode scanning
Scanning needs a live camera stream (getUserMedia) plus a decoder library bundled with your files. Test it early on a mid-range phone: decoders are CPU-hungry, and good lighting matters more than resolution. If your builder's shell doesn't grant camera access to the web view, fall back to <input type="file" accept="image/*" capture> and decode a single photo instead.
Feature checklist
| Test | Expected |
|---|---|
| Tap a file input | System picker opens |
Input with capture | Camera opens; photo returns to the page |
| Location button | Permission prompt, then coordinates |
| Deny each permission | Your fallback appears, nothing freezes |
Questions
Why does my file upload button do nothing in the app?
WebViews need the app shell to provide a file chooser. If tapping does nothing, the shell doesn't support uploads — check your builder's features.
How do I open the camera directly from an input?
Add capture="environment" (rear camera) or capture="user" (front camera) to an input with accept="image/*".
Does geolocation work in a WebView app?
Yes, when the app shell requests the location permission and the page is a secure context. Test on a real phone.