1. Home
  2. Handbook
  3. File upload & camera

// handbook · make it feel like an app

File uploads, camera and location in a WebView app

Upload a profile photo, scan a receipt, find the nearest branch — these work in WebView apps, but each one depends on the app shell asking Android for permission. Here's what your HTML needs and what to test.

updated · 3 min read · APK Builder team

Short answerUse standard web APIs: <input type="file" accept="image/*"> (add capture="environment" to open the camera), navigator.geolocation and getUserMedia. The app shell must implement file choosing and request camera, location or microphone permission; check that your builder supports each feature, serve live sites over HTTPS, and test on a real phone.

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

FeatureWeb APIAndroid permission
Camera photo via file input<input capture>Camera (asked by the shell)
Live camera / QR scanninggetUserMedia({ video: true })Camera
Locationnavigator.geolocationLocation
Voice recordinggetUserMedia({ 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

TestExpected
Tap a file inputSystem picker opens
Input with captureCamera opens; photo returns to the page
Location buttonPermission prompt, then coordinates
Deny each permissionYour 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.

Read next

// ready when you are

Build your APK — free.

No Android Studio, no code, no watermark. Pick your input: