This is a discussion on How can i print out the files in a directory? within the PHP General forums, part of the PHP Programming Forums category; How can i print out all of the files in a directory? I want some output as this: index.php ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I have discovered a very strange thing. The problem is that session management fails when I stop the browser while a PHP page is loading. As soon as the browser requests a file with a session_start or session_register command the browser gets in a kinda endless loop and the session file stay open. The browser keeps waiting and waiting and nothing happens (nothing appears on the screen). I'm using PHP4.3.2 / Debian 3.0 Linux 2.4.20 / Apache 1.3.28 My configure command: './configure' '--with-mysql=../mysql/mysql-standard-4.0.12-pc-linux-i686' '--with-apache=../../apache/build_deb/deb2/apache-1.3.28' '--enable-track-vars' '--disable-debug' '--with-gd' '--enable-ftp' '--enable-inline-optimization' '--enable-sockets' '--with-zlib' Has anyone here have had the same problem and can help me? With regards, Catia Crepaldi |
|
|||
|
hi
please see if this is what you need: http://www.raditha.com/php/dir.php Bas wrote: >How can i print out all of the files in a directory? > >I want some output as this: > >index.php >login.php >image1.gif >image2.jpg > > > -- Raditha Dissanayake. ------------------------------------------------------------------------ http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. |
|
|||
|
"Bas" <bas_timmer49@hotmail.com> wrote in message news:20031017124153.13749.qmail@pb1.pair.com... > How can i print out all of the files in a directory? > > I want some output as this: > > index.php > login.php > image1.gif > image2.jpg Here is a function I use to do just that. <?php function directory() { $handle=opendir("."); while ($filename = readdir($handle)) { $count++; if (!($filename == "." || $filename == ".." || $filename == basename($_SERVER['PHP_SELF']))){ $fd = fopen ($filename, "r"); $contents = fread($fd, filesize($filename)); $dir["$count"] = $filename; } } closedir($handle); sort($dir); foreach($dir as $value){print "<a href=$value>$value</a><br>\n";} } ?> Then just "echo directory();" in your HTML where you want it listed. HTH - JM |
|
|||
|
This has been working for me...
just pass the function the path to the directory you want the listing for. function getDirFiles($dirPath){ if ($handle = opendir($dirPath)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $filesArr[] = trim($file); } } closedir($handle); } return $filesArr; } hth, Craig -----Original Message----- From: Bas [mailto:bas_timmer49@hotmail.com] Sent: October 17, 2003 6:42 AM To: php-general@lists.php.net Subject: [php] How can i print out the files in a directory? How can i print out all of the files in a directory? I want some output as this: index.php login.php image1.gif image2.jpg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|||
|
you can use simply
exec("ls -l 2>&1;", $output) : if on linux OR exec("dir 2>&1;", $output) : if on windows Enjoy Nitin ----- Original Message ----- From: "Craig Lonsbury" <craig@topdraw.com> To: "Bas" <bas_timmer49@hotmail.com>; <php-general@lists.php.net> Sent: Friday, October 17, 2003 8:40 PM Subject: RE: [php] How can i print out the files in a directory? > This has been working for me... > just pass the function the path to the directory you > want the listing for. > > function getDirFiles($dirPath){ > if ($handle = opendir($dirPath)) { > while (false !== ($file = readdir($handle))) { > if ($file != "." && $file != "..") { > $filesArr[] = trim($file); > } > } > closedir($handle); > } > return $filesArr; > } > > hth, > Craig > > -----Original Message----- > From: Bas [mailto:bas_timmer49@hotmail.com] > Sent: October 17, 2003 6:42 AM > To: php-general@lists.php.net > Subject: [php] How can i print out the files in a directory? > > > How can i print out all of the files in a directory? > > I want some output as this: > > index.php > login.php > image1.gif > image2.jpg > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > |