Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file manager

Status
Not open for further replies.

cyberwolf14

Programmer
Aug 27, 2001
65
BE
Hi

I'm worki,g on a file manager in php but i want to now the names of the files on my website

for example there are 2 files on my website and i want to now the names of the 2 files

How do i do that with php??
 
Is this possible?? My site: msn/email: matthiasdeschagt@hotmail.com
icq: 123118841
online
 
of course ...

This function gives you an array with the list of FILES of a directory ... It should help you out now.

function seekdir($dir) {
$files=array();
$i=0;
$handle = opendir($dir);
while ($file = readdir($handle)) {
if(($file != '.') && ($file != '..')) {
if(!is_dir($file)) $files[$i++]=$file;
}
}
closedir($handle);
return $files;
}

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Could I just tag a question to the bottom of this? thanks :)
Obviously ignoring . and .. is a GoodThing(tm) but how (and trust me I spent hours trying last night) do you specify only files with a .php extension for the list?

thanks in advance,
Karv
------------------------------------------------------------ I can't have sent that email, it says from Superuser.
 
That function retrieves all the files of one dir. If you want only the files with .php as extension you should change the function.

This is a start point to solve this problem. If you need some thing similar, you should adjust this solution to your case. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Try adding another condition like this:
Code:
     if(($file != '.') && ($file != '..') && ereg("\\.php\$",$file)) {

-Rob
 
Thanks Rob .. its the second \ that got me, otherwise I was spot on :)
Note to self: seeing double can occur when not drunk. I can't have sent that email, it says from Superuser.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top