![]() |
folder scan
Hello
i have to scan file in folder and other file in subfolder also , list in one page. All file display in one page. e.g folderfiles 1.jpg 2.jpg etc And folder/subfolder file 12.jpg 13.jpg etc so can anyone please guide me. |
hi
i have this script can you tell me why it not list all file just list one folder and one file. Script is here PHP Code:
like Directory Name: new folder newfolder2 FIle Name : 1.jph 2.jpg Hope SOmeBody will help |
SPL is typically the way to go for new development, but that's not where your problem is. I will present both solutions.
Here are the problem areas: PHP Code:
$allData['file'] and $allData['dir'] arrays, and is instead overwriting previously stored values on each iteration.Here's a solution using your method.. excuse me for renaming a couple of variables I believe were inappropriately named. PHP Code:
PHP Code:
Also, your output loop must be designed to handle your 2-dimensional array. Here's an example, although concise and particularly obfuscated. PHP Code:
Code:
Files: |
nice and thanx for reply bro
but plz tell me how what change i have to do for sub folder file listing also in your script you know what i really want to is e.g Folder Files: Directory: Subfolder1 Files: Directory: Subfolder2 Files: Directory: Subfolder3 Files: Directory: SOmewhat recruit directory listing but in i wan to seperate file and directory all file and folder should list in with their files in one page. |
I'm not entirely sure what you mean, but here's a quick mock up of a modified function using SPL which will recurse through subdirectories, build and return an output string with padding for recursion depth. I'm at work right now, so cut me some slack if it produces unexpected results! :-P
PHP Code:
Code:
.RecursiveIteratorIterator and RecursiveDirectoryIterator are the workhorses here. There's also a bit of string manipulation in order to produce that particular output, and you can also define the amount of padding per recursion depth by modifying the $padding variable. The constants PHP_EOL (new line) and DIRECTORY_SEPARATOR (/ or \) are platform-independent and defined by PHP at run-time.If this is a web application you'll have to insert HTML line breaks by each PHP_EOL and replace leading spaces with to see the formatting using an text/html MIME type. For example:PHP Code:
Cheers. |
Nice work and thanks ++
bro i understand my query 100% and solve my problem actually what i want to make form your script is like this , which i make from below script PHP Code:
i have to manually add while loop in it , and it make script big, i wan to short this script as much as possible... My main aim is , i have to scan file from all folder and move them to one folder. |
| All times are GMT. The time now is 09:51 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0