Hi all,
i've some problem with a script that should read the content of a folder and print the content in a table, and near each files name , i display a checkboxes that if checked and pressed the button delete it will delete from the server the file.
Now this is the file taht read and print the result:

PHP Code:
<?php
function listFiles($dir,$type) { 
    if (
strlen($type) == 0$type "all"
    
$x 0
    if(
is_dir($dir)) { 
        
$thisdir dir($dir); 
        while(
$entry=$thisdir->read()) { 
            if((
$entry!='.')&&($entry!='..')) { 
                if (
$type == "all") { 
                    
$result[$x] = $entry
                    
$x++; 
                    
next
                } 
                
$isFile is_file("$dir$entry"); 
                
$isDir is_dir("$dir$entry"); 
                if ((
$type == "files") && ($isFile)) { 
                    
$result[$x] = $entry
                    
$x++; 
                    
next
                } 
                if ((
$type == "dir") && ($isDir)) { 
                    
$result[$x] = $entry
                    
$x++; 
                    
next
                } 
                
$temp explode("."$entry); 
                if ((
$type == "noext") && (strlen($temp[count($temp) - 1]) == 0)) { 
                    
$result[$x] = $entry
                    
$x++; 
                    
next
                } 
                if ((
$isFile) && (strtolower($type) == strtolower($temp[count($temp) - 1]))) { 
                    
$result[$x] = $entry
                    
$x++; 
                    
next
                } 
            } 
        } 
    } 
    return 
$result

/* directory e estensione files */
$files listFiles("./","jpg"); 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Download</title>
<style type="text/css">
td { 
    font- family:Verdana,Geneva,Arial,Helvetica,sa
ns-serif;
    font-size:11px
}
</style>
</head>
<body bgcolor="#ffffff" link="#ff8000" vlink="#00659C" alink="#00659C">
<form action="cancella.php" method=\"POST\">
<table cellpadding='1' cellspacing='0' border='0' bgcolor='black' width='552' align='center'>
 <tr>
  <td><br>  
<?php
if (isset($files)) { 
    echo 
"<font color=white>Numero di file(s): <b>".count($files)."</b></font><br><br>";  
    
$cols 2;
    
$width round(100 $cols);
    
$ret "<table border=0 cellspacing=2 width=\"100%\" bgcolor=white><tr><td valign=top width=\"$width%\">";
    
$numtot count($files);
    
$numto 1.0 $cols;
    
$step 1.0 $numtot;
    
$numfile 0.0;
    foreach (
$files as $value) { 
        
$numfile += $step;
        
$ret .= "<input type=\"checkbox\" name=\"del[]\" id=\"$value\">  $value  <a href=\"http://mysite.com/upload/$value\" target=\"_new\">Guarda</a><br>";// <== modifica
        
if (($numfile+0.0000001)>=$numto) {
                
$ret.= "</td><td valign=\"top\" width=\"$width%\">";
                
$numfile -= $numto;
        }
    }
    
$ret ereg_replace("</td><td valign=\"top\" width=\"$width%\">$","",$ret);
    
$ret .= "</td></tr></table>$files";
    echo 
$ret;
}
?>
  </td>
 </tr>
</table><br>
<center><INPUT type="SUBMIT"  value="Cancella"></center>
</form>
</body>
</html>
And this is the file cancella.php:

PHP Code:
foreach($_POST['del'] as $path => $key
   if(
$keyunlink($path); 
But when i go to press the button "Cancella", it returns to me:

Warning: Invalid argument supplied for foreach()
I've read that this is beacuse the array $POST is NULl, bot after all, how can i solve this problem?!?!

byez all