Form changes Horizon - Upload Daily Field Work Photo
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m24s Details

This commit is contained in:
Tanuja Pansare 2026-10-30 10:27:41 +05:30
parent d9fa99e414
commit de0ef5dcaa
1 changed files with 35 additions and 21 deletions

View File

@ -368,9 +368,10 @@
$('#start-photo-camera').on('click', async function () { $('#start-photo-camera').on('click', async function () {
try { try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
throw new Error('Camera access is not supported by this browser.'); throw new Error('Camera access requires HTTPS or localhost.');
} }
// This triggers the browser's native camera permission prompt
photoStream = await navigator.mediaDevices.getUserMedia({ photoStream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: { ideal: 'environment' } }, video: { facingMode: { ideal: 'environment' } },
audio: false audio: false
@ -385,12 +386,25 @@
$('#retake-photo').hide(); $('#retake-photo').hide();
} catch (error) { } catch (error) {
console.error('Camera error:', error);
if (error.name === 'NotAllowedError' ||
error.name === 'PermissionDeniedError') {
Swal.fire({
icon: 'warning',
title: 'Camera Permission Required',
text: 'Please allow camera access in your browser settings and click Open Camera again.'
});
} else {
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Camera Unavailable', title: 'Camera Unavailable',
text: 'Please allow camera access and try again.' text: 'Unable to access your camera. Please check your camera and try again.'
}); });
} }
}
}); });
$('#capture-photo').on('click', function () { $('#capture-photo').on('click', function () {