![]() |
[PHP] Ordner auslesen
Hi ich hab ne Frage und zwar brauch ich ne Funktion, die mir alle Files eines bestimmten Dateityps in ein Dropdown macht und das ganze per PHP. Ich schaff zwar, dass es mir alle Files per echo auflistet (iss ja auch net wirklich schwer), jedoch krieg ich das mit dem Dropdown nicht gebacken. Die Fileliste hab ich in ein Array gemacht...
|
Re: [PHP] Ordner auslesen
wo ist das problem ? :drunken:
die struktur des dropdowns (SELECT) sieht ja so aus:
Code:
wenn du das ganze (die dateinamen) schon in einem array
<select name="testdrop">
<option value="Datei 1"></option> <option value="Datei 2"></option> <option value="Datei 3"></option> </select> gespeichert hast, dann kannst du sie doch alle mit ForEach auslesen
SQL-Code:
PS.: Hab's nicht getestet !
<?php
$i = 1; echo "<select name=\"testdrop\">"; foreach ($deinArray as $ausgabe){ echo "<option value=\"Datei ".$i."\">".$ausgabe."</option>"; $i++; } echo "</select>"; ?> |
Re: [PHP] Ordner auslesen
Hm ok das ganze funktioniert, aber nun hab ich soviele ComboBoxen, wie Dateien in dem Ordner sind :?:
Hier mal der Quelltext des ganzen:
Code:
<?php
$path = 'images/'; $handle=opendir($path); while ($file = readdir ($handle)) { if ($file != "." && $file != "..") { $array[] = $file; } } closedir($handle); sort($array); foreach($array as $file) { echo "<select name=\"testdrop\">"; $replace = ""; $file = str_replace(".JPG", $replace, $file); $i = 1; echo "<option value=\"Datei ".$i."\">".$file."</option>"; $i++; echo "</select>"; } ?> |
Re: [PHP] Ordner auslesen
Soo ich hab das ganze nun endlich geschafft hier der Quelltext nochmal:
Code:
<?php
$path = 'images/'; $handle=opendir($path); while ($file = readdir ($handle)) { if ($file != "." && $file != "..") { $array[] = $file; } } $i = 1; closedir($handle); sort($array); echo "<select name=\"testdrop\">"; foreach($array as $file) { $replace = ""; $file = str_replace(".JPG", $replace, $file); echo "<option value=\"Datei ".$i."\">".$file."</option>"; $i++; } echo "</select>"; ?> |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz