Re: Directory Contents Listing

From: Date: Wed, 28 Nov 2001 11:46:16 +0000
Subject: Re: Directory Contents Listing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75883@lists.php.net to get a copy of this message
Here is my PHPCommander <1000bytes <?php var_dump($HTTP_POST_VARS); if (@!$HTTP_POST_VARS['dir']) $HTTP_POST_VARS['dir']='./'; if (is_dir($HTTP_POST_VARS['dir'])){ echo '<form method="post" action="'.$PHP_SELF.'" name="ok">'; echo "<input type='hidden' name='dir' value='".$HTTP_POST_VARS['dir']."'></form>"; if ($dir = @opendir($HTTP_POST_VARS['dir'].'/')) { while($file = readdir($dir)) { if (is_file($HTTP_POST_VARS['dir']."/$file")){ $fsize=filesize($HTTP_POST_VARS['dir']."/$file"); }else{ $fsize=0; } printf("<pre>%120s,%10d</pre><br>\n","<a href='javascript:document.ok.elements[\"dir\"].value=\"".$HTTP_POST_VARS['dir']."/".$file."\";document.ok.submit();'>$file</a>",$fsi ze); } closedir($dir); } }else{ echo "<a href=\"javascript:history.go(-1);\">Back</a><br><br>"; $ar=file($HTTP_POST_VARS['dir']); while (list($k,$v)=each($ar)){ $ln+=strlen($v); if ($ln>0){ echo htmlspecialchars($v)."<br>\n"; } } } ?> Enjoy Andrey Hristov ----- Original Message ----- From: <Rea_David@emc.com> To: <deepndra@icimod.org.np>; <php-general@lists.php.net> Sent: Wednesday, November 28, 2001 1:38 PM Subject: RE: [PHP] Directory Contents Listing > Here's an example code I use > > <? > // print the current directory in unordered list > print("<UL>\n"); > > // get each entry within the directory & return to user with the > link > $myDirectory = dir("."); > while($entryName = $myDirectory->read()) > { > if ($entryName != "." && $entryName != ".." > && $entryName != > "index.php"){ > print("<LI><a href=$entryName>$entryName > \n</a>"); > } > } > ?> > > Hope it helps! > > -----Original Message----- > From: Steve Werby [mailto:steve-lists@befriend.com] > Sent: 28 November 2001 05:39 > To: Deependra B. Tandukar; php-general@lists.php.net > Subject: Re: [PHP] Directory Contents Listing > > > "Deependra B. Tandukar" <deepndra@icimod.org.np> wrote: > > How do I display the directory contents using PHP? > > See readdir() in the online manual. I'm pretty sure it even has example > code you could paste in. > > -- > Steve Werby > President, Befriend Internet Services LLC > http://www.befriend.com/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#75883) next »