Status
Not open for further replies.

saninokia

Active Member
929
2010
71
15
i am making a php based filemanager but getting some problem,i am trying to show all files from a directory with checkbox system and in a table,but if only 1 file is stored in the directory then its ok but if many files then its not fit in the table list.i need help,please guys.

my code is:

PHP:
<?php
$filespath = dirname(__FILE__)."/files/";
if ($dir = opendir($filespath))
{
 $images = array();
 while (false !== ($file = readdir($dir)))
 {
  if ($file != "." && $file != "..")
   {
    $images[] = $file; 
   }
 }
?>
<div id="filelist">
<table width="400px" align="center">
<tr><td>Click</td><td>Files</td><td>File Size</td></tr>
<?
foreach($images as $image)
{
?>
<tr><td><input type="checkbox" name="files[]" value="<? echo $image;?>" /></td><td><? echo $image;?></td><td><? echo filesize($filespath.$image)."KB";?></td></tr>
</table>
</div>
<?
}
	closedir($dir);
}
?>
 
9 comments
Try this:
PHP:
<?php 
$filespath = dirname(__FILE__)."/files/"; 
if ($dir = opendir($filespath)) 
{ 
 $images = array(); 
 while (false !== ($file = readdir($dir))) 
	 { if ($file != "." && $file != "..") {$images[] = $file;} } 
	echo "<div id='filelist'><table width='400px' align='center'><tr align=center><td>Click</td><td>Files</td><td>File Size</td></tr>";
	foreach($images as $image) 
	{ 
		$size = filesize($filespath.$image).' KB';
		echo "<tr align=center><td><input type='checkbox' name='files[]' value='$image' /></td><td>$image</td><td>$size</td></tr>";
	} 
    echo '</table></div> ';
    closedir($dir); 
} 
?>
 
Status
Not open for further replies.
Back
Top