back-end ustreamer, GPS, timelapse, and photo-refresh site working
This commit is contained in:
22
files/image_refresh_php/getImage.php
Normal file
22
files/image_refresh_php/getImage.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
// Path to the directory where the images are stored
|
||||
$imageDirectory = 'capture/';
|
||||
// Get the list of image files in the directory
|
||||
$imageFiles = glob($imageDirectory . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
|
||||
// If there are no image files, return a default image
|
||||
if (empty($imageFiles)) {
|
||||
$defaultImage = 'default.jpg'; // Provide path to your default image
|
||||
header('Content-Type: image/jpeg'); // Adjust content type if default image type is different
|
||||
readfile($defaultImage);
|
||||
exit;
|
||||
}
|
||||
// Sort the image files by modification time, latest first
|
||||
array_multisort(array_map('filemtime', $imageFiles), SORT_DESC, $imageFiles);
|
||||
// Get the path to the latest image file
|
||||
$latestImage = $imageFiles[0];
|
||||
// Set header type
|
||||
header('Content-Type: image/jpeg');
|
||||
// Get the image
|
||||
readfile($latestImage);
|
||||
?>
|
||||
Reference in New Issue
Block a user