Autor | Zpráva | ||
---|---|---|---|
H13 Profil |
#1 · Zasláno: 30. 1. 2007, 16:31:09
Ahoj potřeboval bych poradit, jak udělat php skript, který vypíše data ze složky (soubory, podsložky), např.
vypis ze slozky 'slozka': - slozka/obrazky/obrazek.png - slozka/obrazky/druhy_obrazek.png - slozka/soubory/prvni_soubor.png - slozka/index.html ... díky za jakoukoliv radu |
||
Paulí Profil * |
#2 · Zasláno: 30. 1. 2007, 16:59:57
zkus tohle :
<? function recrusive_dirlist($base_dir) { global $getDirList_alldirs,$getDirList_allfiles; function getDirList($base) { global $getDirList_alldirs,$getDirList_allfiles; if(is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if (is_dir($base ."/". $dir) && $dir !== '.' && $dir !== '..') //note the change in this line { $subs = $dir ; $subbase = $base ."/". $dir;//note the change in this line $getDirList_alldirs[]=$subbase; getDirList($subbase); } elseif(is_file($base ."/". $dir) && $dir !== '.' && $dir !== '..')//change in this line too { $getDirList_allfiles[]=$base ."/". $dir;//change in this line too } } closedir($dh); } } getDirList($base_dir); $retval['dirs']=$getDirList_alldirs; $retval['files']=$getDirList_allfiles; return $retval; } // příklad použití: echo '<pre>'; print_r(recrusive_dirlist('./')); echo '</pre>'; ?> Ale musíš změnit složku , ve které chceš zobrazit soubory a podložky takže změň hodnotu na 3. řádku od spoda , jak tam je "print_r(recrusive_dirlist('./'));" tak to změň třeba na "print_r(recrusive_dirlist('/moje_slozka/'));" ......... chápeš ??? |
||
k Profil * |
#3 · Zasláno: 30. 1. 2007, 17:10:50
Paulí
eh.. zajimavy zpusob psani kodu.. |
||
Paulí Profil * |
#4 · Zasláno: 30. 1. 2007, 17:13:19
pro :"k"
A proč ??? |
||
k Profil * |
#5 · Zasláno: 30. 1. 2007, 17:17:52
mit metodu v dalsi metode? Proc?
|
||
Paulí Profil * |
#6 · Zasláno: 30. 1. 2007, 17:18:40
Ale funguje to - klidně ozkoušej !!!
|
||
k Profil * |
#7 · Zasláno: 30. 1. 2007, 17:25:17
netvrdim ze to nefunguje(nevim - urcite to bude hazet par notice). tvrdim ze je to zajimave napsane.
function recrusive_dirlist($base) { $getDirList_alldirs = array(); $getDirList_allfiles = array(); if(is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if (is_dir($base ."/". $dir) && $dir !== '.' && $dir !== '..') //note the change in this line { $subs = $dir ; $subbase = $base ."/". $dir;//note the change in this line $getDirList_alldirs[]=$subbase; getDirList($subbase); } elseif(is_file($base ."/". $dir) && $dir !== '.' && $dir !== '..')//change in this line too { $getDirList_allfiles[]=$base ."/". $dir;//change in this line too } } closedir($dh); } } $retval = array(); $retval['dirs']=$getDirList_alldirs; $retval['files']=$getDirList_allfiles; return $retval; } tohle udela to same a neni potreba mit v te metode dasli metodu.. |
||
H13 Profil |
#8 · Zasláno: 30. 1. 2007, 17:31:03
Paulí
k díky moc |
||
Paulí Profil * |
#9 · Zasláno: 30. 1. 2007, 18:09:41
pro "k"
A jakto , že mě to nejde ??? a kde máš místo na zadání , ze které složky to má být zobrazeno ??? |
||
k Profil * |
#10 · Zasláno: 30. 1. 2007, 18:17:46
Paulí
Prosimte.. Upravoval jsem tu funkci, proto jsem vypsal jen ji. H13 urcite vi jak ji zavolat a predat ji parametr. |
||
Časová prodleva: 17 let
|
Toto téma je uzamčeno. Odpověď nelze zaslat.
0