Bluehost.com Web Hosting $6.95

How can i print out the files in a directory?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2003
Bas
 
Posts: n/a
Default 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
Reply With Quote
  #2 (permalink)  
Old 10-17-2003
Catia Crepaldi
 
Posts: n/a
Default Problem with session management

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
Reply With Quote
  #3 (permalink)  
Old 10-17-2003
Raditha Dissanayake
 
Posts: n/a
Default Re: [PHP] How can i print out the files in a directory?

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.
Reply With Quote
  #4 (permalink)  
Old 10-17-2003
Jim Moseby
 
Posts: n/a
Default Re: How can i print out the files in a directory?


"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


Reply With Quote
  #5 (permalink)  
Old 10-17-2003
Craig Lonsbury
 
Posts: n/a
Default 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
Reply With Quote
  #6 (permalink)  
Old 10-17-2003
Nitin
 
Posts: n/a
Default Re: [PHP] How can i print out the files in a directory?

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
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:25 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0