Hi.
I have folders that contain images that has to be displayed in a website. I can’t name them in my
[code]<option></option>
in a static manner because they are dates.
this is the html code:
[code]
<select multiple class=”form-control”>
<option selected disabled>Select an Initialization Date</option>
<option selected value=”archived_date1″></option>
<option value=”archived_date2″></option>
<option value=”archived_date3″></option>
<option value=”archived_date4″></option>
<option value=”archived_date5″></option>
<option value=”archived_date6″></option>
<option value=”archived_date7″></option>
<option value=”archived_date8″></option>
</select>
I tried to use the
[code]scandir ()
but I it only lists the folders in my specified directory.
This was my test with
[code]scandir
:
[code]
$completepath=(‘../operations/archived_runs/pywrf_output/d01’);
// scan dir
$date=scandir($completepath);
print_r($date);
this was the output:
[code]
[]Array ( [0] => . [1] => .. [2] => 20220727_1500 [3] => 20220727_1800 [4] => 20220727_2100 [5] => 20220728_0000 [6] => 20220728_0300 )
I was hoping to incorporate this functionality in my php script that displays images.
[code]
ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);
// GET PARAMETERS
$date_folder = $_GET[‘date_folder’];
$domain = $_GET[‘domain’];
$path = $_GET[‘path’];
// create the completepath from these values
$completepath=(‘../operations/archived_runs/pywrf_output/’ . $domain . ‘/’ . $date_folder . ‘/’ . $path);
$images=glob($completepath . ‘/*png’);
$archived_data = [];
// loop
$step = 1;
for ($i = 0; $i < count($images); $i+=$step) {
$img = $images[$i];
$archived_data[] = [‘img’ => $img];
}
echo json_encode($archived_data);