473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Read files and folders recursively

MarkoKlacar
296 Expert 100+
Hi,

Is there a way to recursively select folders and upload the files in the current, so to speak, folder?

I know that there exists a possibility to upload a file in the same folder that the php script is executed, what I'm really looking for is a way to loop through all the folders.

Thanks in advance!
Mar 7 '08 #1
4 2100
satas
82
Yes, it's possible with glob() function :
http://php.net/manual/en/function.glob.php
Mar 7 '08 #2
ronverdonk
4,258 Expert 4TB
Yes, it's possible with glob() function :
http://php.net/manual/en/function.glob.php
glob() is not recursive. It is easier and a lot faster to use opendir() and readdir().

Ronald
Mar 7 '08 #3
satas
82
glob() is not recursive. It is easier and a lot faster to use opendir() and readdir().

Ronald
Yes it is. I've meant that it is much easier to use glob() function to get folder's tree instead of odendir+readdir. Of course, you should write a function which will be able to scan folders. I'll post here my own written function for it, if ill find it :)
Mar 9 '08 #4
satas
82
Here it is:

[PHP]
function ShowTree($parent_dir) {
//node counter
static $i = 0;
$i++;

$dirs = glob($parent_dir . '/*', GLOB_ONLYDIR);
$cnt = count($dirs);

if ($cnt > 0) {
print("<ul>");

foreach ($dirs as $dir) {
// strip ../
print substr($dir, 3, strlen($dir));
ShowTree($dir);
}

print("</ul>");
}
}
[/PHP]

Note: i've just strip a lot of unnecessary code so function may not work (can't test it at the moment). But the main idea is clear, i hope.
Mar 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Adam Clauss | last post by:
I have a folder containing many subfolders (and subfolders and....) all containing various .cs files. Is there any "easy" way to get them all added to the solution. Preferable would be that the...
2
by: melo | last post by:
Hello, I've been struggling with a function(s) to recursively set all folders and files to NOT read-only. So, I thought I'd post this message. What I need to do is: given a starting path, I...
1
by: ltt19 | last post by:
Hi Does anybody knows hot to Get all directories and files in a HDD. I took a look at System.IO.IsolatedStorage.IsolatedStoregeFile but I could not specify the HDD that i want (for example D: or...
9
by: Bill Nguyen | last post by:
I need a VB routine to loop thru a select top folder to find all subfolders and list all subfolders/files under each of these subfolders. Any help is greatly appreciated. Bill
2
by: AtulSureka | last post by:
Hi, I want to determine the total number of files and folders in the given directory. I have a solution to go recursively on each folder and make a count . But I do not want to go recursively...
2
by: express99 | last post by:
i am new to perl scripting. i want to be able to delete folders and files older than n days recursively in a windows environment.
2
by: halimunan | last post by:
hello all, how do i delete all folders and files inside a directory while at the same time keeping(not deleting the directory) ? e.g : i want to delete all folders and files inside c:\temp it...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
14
by: Airtech | last post by:
I am using the AllenBrowne code of "filldirlisttotable" to provide some functions for a media library manager I am building in access 2003. I have four checkboxes which if all four are not turned...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.