answersLogoWhite

0

To list all the files in a directory you would use the following: $handle = opendir('/path/to/folder');

while(($file = readdir($handle)) !== false){

// do things with files

// you will want to filter out things like ., .., and .htaccess

echo $file;

}

Also, to return a list of all the files in a directory, especially with wildcards, use something such as:

$file_array = glob("*"); $files = implode("\n", $file_array);

echo $files;

will give you a list of all the files directly.

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

Can .php files be executed when saved in other location than its web's root directory?

They can execute if you use include or require and show the full path of external php file in the www folder based php file.


How do you change the current directory in PHP?

chdir() PHP function helps in changing the current directory.


What is the command to be used to see all the files in a directory?

The command in a terminal is: ls (short for List). This will list the files in the current directory. Whilst in the Home directory, to list the files in a different directory, for instance Videos, use: ls Videos.


Will php 4.4.7 server support php 5 files?

Yes php 4.4.7 server support php 5 files. But most of the php 5 features are not supported by php 4.4.7 version


Shell programming to list all directory files to a directory?

for i in * do if [ -d $i ]; then echo $i directory >> /tmp/directories fi done


How do you get the current working directory in PHP?

$curr_dir = getcwd();


How do you enable PHP sessions?

Find your php.ini file (which holds all the settings for PHP, and how it should work).Under the "sessions" section, find the directive "session.save_hander." Unless you're directed otherwise, and you want sessions enabled, this directive should be set to the string "files."If session problems arise, find the directive "session.save_path," and make sure the current path it's set to actually exists (and that PHP can write to it). PHP does not create this directory; you need to.Still not working? Go to the directory path that session files are saved in (as noted in the "session.save_path" directive) and see if there are session files being created when you start a session in a PHP script. If they are, then your scripts are most likely the problem. If the newly created sessions are empty, make sure that you are actually putting data in them, and that you're not resetting the $_SESSION global variable anywhere.If they aren't, then it may help to reinstall PHP, or get further assistance elsewhere.


How do you decompress PHP files?

PHP isn't generally a compressed file, so it all depends on what format it was compressed into. Hope this has helped, Cpl.Vadera


How do you copy all the files from etc directory to oracle in unix?

You will need to be more clear about the target - is 'oracle' a directory?


Which Linux command will delete a directory as well as all its files and sub directories?

rm -rv /path/to/directory


How do you transfer multiple files from one directory to another in UNIX os?

The easiest way is to use the 'cp' command. Put the name of all the files in the 'cp' command line and use another directory as the target; all the files will be copied to the new directory. Note: you may need to use the -r (recursive) copy option if you have subdirectories in the source directory.


What is a java directory?

collection of files and directory