He who is skilled at the Filesystem functions of PHP... Enter

dcpsoguy

Diamond Member
Nov 5, 2000
3,252
0
0
I see functions for last modified, last accesed, but what is the function to just list the filename and its extension
 

Jfur

Diamond Member
Jul 9, 2001
6,044
0
0
is that title from Plato's academy..? :)

Sorry, no answer to the question :(
 

dcpsoguy

Diamond Member
Nov 5, 2000
3,252
0
0
Just in case you are wondering, I wanna retrieve all filenames in a directory? Is there a function for this?
 

Elledan

Banned
Jul 24, 2000
8,880
0
0
I checked the PHP documentation, but I didn't see any function which will list the contents of a folder.

Why do you want to do this?
 

JustinSampson

Senior member
Aug 11, 2001
481
0
0
Here's somthing I made to list all files in a directory:

<?php

if ($submit == &quot;Create my List!&quot;)
{

$fp = fopen($filename,&quot;w+&quot;);
$handle = opendir(&quot;$folder&quot;);
while (false!==($file = readdir($handle))) {
if ($file != &quot;.&quot; &amp;&amp; $file != &quot;..&quot;) {

$file = ereg_replace (&quot;.zip&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.ace&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.rar&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.cab&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.avi&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.exe&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.mpeg&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;.mpg&quot;, &quot;&quot;, $file);
$file = ereg_replace (&quot;_&quot;, &quot;&quot;, $file);
$file = ereg_replace ($filename, &quot;&quot;, $file);
$file = ereg_replace (&quot;.txt&quot;, &quot;&quot;, $file);


$file = &quot;$file\r\n&quot;;
fwrite( $fp, $file);
}
}
closedir($handle);
fclose( $fp );
echo &quot;List created! Click <a href=\&quot;$filename\&quot;>here</a> to view it<P>
<a href=\&quot;$PHP_SELF\&quot;><- Create Another List</a>&quot;;

}
if ($submit != &quot;Create my List!&quot;)
{
echo &quot;<form action=\&quot;$PHP_SELF\&quot; method=\&quot;POST\&quot;>
Directory: <input type=\&quot;text\&quot; name=\&quot;folder\&quot; value=\&quot;C:\download\&quot;><br>
File Name<input type=\&quot;text\&quot; name=\&quot;filename\&quot; value=\&quot;list.txt\&quot;><p>
<input type=\&quot;submit\&quot; name=\&quot;submit\&quot; value=\&quot;Create my List!\&quot;>
</form>&quot;;
}
?>

Have a look throught and try it it out.
 

Elledan

Banned
Jul 24, 2000
8,880
0
0
Readdir()

This function appears to be what you're looking for :)

JustinSampson used it in his script as well, but I though I would just provide a link to the documentation.