It works when execute from IDLE and Console, but when I trigger python script from PHP the PiCamera won't work.
import picamera from PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.capture('/home/pi/Pictures/image.JPEG')
camera.stop_preview()
camera.close()
<?php
$command = escapeshellcmd('python3 /home/pi/Downloads/code.py');
$output = shell_exec($command);
echo $output;
?>