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

@ -366,33 +366,47 @@
const photoInput = document.getElementById('field-upload_photo');
$('#start-photo-camera').on('click', async function () {
try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
throw new Error('Camera access is not supported by this browser.');
}
try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
throw new Error('Camera access requires HTTPS or localhost.');
}
photoStream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: { ideal: 'environment' } },
audio: false
});
// This triggers the browser's native camera permission prompt
photoStream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: { ideal: 'environment' } },
audio: false
});
video.srcObject = photoStream;
video.style.display = 'block';
preview.style.display = 'none';
video.srcObject = photoStream;
video.style.display = 'block';
preview.style.display = 'none';
$('#start-photo-camera').hide();
$('#capture-photo').show();
$('#retake-photo').hide();
$('#start-photo-camera').hide();
$('#capture-photo').show();
$('#retake-photo').hide();
} catch (error) {
Swal.fire({
icon: 'error',
title: 'Camera Unavailable',
text: 'Please allow camera access and try again.'
});
}
} 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({
icon: 'error',
title: 'Camera Unavailable',
text: 'Unable to access your camera. Please check your camera and try again.'
});
}
}
});
$('#capture-photo').on('click', function () {
if (!photoStream || !video.videoWidth) {
return;