Disable photo preview when taking an image trough browser

I have a button that when clicked opens the camera of the device and allows the user to take a photo and then upload it. However, when photo is taken a preview of it is shown on the display and there are Retake & Submit buttons (This is behavior in IOS). Is there a way to stop this from happening and straight up close the camera, and upload the photo after the user presses the shutter button?

Here is the code I am using to invoke the camera:

          $('#cameraInput').on('change', function(e) {
                handleFileSelect(e);
            });
        
            function handleFileSelect(event) {
                const input = event.target;
        
                if (!input.files || !input.files[0]) {
                    return;
                }
        
                const reader = new FileReader();
        
                reader.onload = function(e) {
                    // Upload the image to your server immediately
                    uploadImageToServer(e.target.result);
                };
        
                reader.readAsDataURL(input.files[0]);
            }

If that is not possible is there an alternative? Like some kind of JS library that will show the camera feed directly in the browser but still have the basic controls like changing the lens the camera uses, enabling/disabling the flash?