Hello,
I am creating a blog for a company and they are most likely to want images in it. I could tell them to work out the path of the image but i would rather i could have some sort of folder browsing script so that they click on the file they want etc.
All i need to know is how to browse the folder. I can work the rest out.
Thanks,
Ben
Browse Folder and get file path
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You can list files on your server by doing something like:
Remember that "." and ".." will appear in the list of files. Also, directories and files will be found, so use is_dir() to check if it's a directory since you can't download a directory... you'll want to change $path to $path . "/" . $file if it's a directory.
Hopefully that was vague enough to push you in the right direction
Code: Select all
$handle = opendir($path);
while (false !== $file = readdir($handle)) {
echo $file . "<br/>";
}
closedir($handle);Hopefully that was vague enough to push you in the right direction