View Full Version : Reading a directory question

11-02-2006, 05:13 PM

I have a site with multiple users. They each have their own home folder. Inside this folder they have a upload_temp directory and a gallery directory.

When they ftp images into their upload_temp directory, I need to (using php) look into that directory see if there are any files, grab them, insert info into my DB, then take the ImageID generated for each file and rename each file after the ImageID, move the file to the gallery folder and remove the temp file.

So what I need to know is how do I

1. look into a directory and see if there are files
2. grab the names of all the files and place them into an array that I can loop through, inserting , rename, move and then remove.

so if my directory name is upload_temp, is there a function in php that will read all the files uploaded and place the names into an array or something to that effect? I know how to rename and move files, I just need to know how to check the directory for files within and place them into an array.

thank you for any help with this.

11-02-2006, 09:26 PM
grep() (http://www.php.net/grep)
scandir() (http://www.php.net/scandir)
opendir() (http://www.php.net/opendir)/dir class (http://www.php.net/dir)