PHP: Get all files and folders from a directory (folder) PHP: Saznajte sve datoteke i mape iz direktorija (mapa)
Posted on 16. Poslano na 16. Jun, 2009 by Dragos in Coding , PHP Jun, 2009 by Dragos u kodiranju, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Da biste dobili sve datoteke i mape iz direktorija (mape) Našao sam scandir biti idealno rješenje.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenira direktorij i vraća niz koji sadrži sve datoteke i direktorije pod Parent Directory we're looking in
The code below will try to remove a directory, if the element is a directory or delete a file, if respectively the element is a file. Kod ispod će pokušati ukloniti direktorij, ako je element direktorija ili izbrisati datoteku, ako odnosno element je datoteka.
$lookin='./home/folder'; $ lookin = '. / home / mapu'; $elements=scandir($lookin); $ elementi scandir = ($ lookin); foreach($elements as $singleEl) { foreach ($ $ elemenata kao singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); else drugi unlink($lookin.'/'.$singleEl); otkačiti ($ lookin .'/'.$ singleEl); } )
Related posts: Related posts:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kako jednostavno onemogućiti pristup do mape s htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kako biste dobili indeks (poziciju unutar grupe) s jQuery objekt?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Gdje mogu pronaći Sve nekretnine za sve HTML elemenata?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Kako doći vrijeme stvaranja datoteke sa PHP na Linux strojevima
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator za Wordpress, dobiti slobodan promet iz potpuno automatizirana skripta čep












































