PHP beginner |
|
Hallo ik heb een scripje om files te verwijderen, maar er komt geen lijst met files.. Weten jullie waarom niet?
het script:
<?php
$cat = $_GET['c'];
function checkdir($map)
{
chmod($map, 0777);
$open = opendir($map);
while(false != ($lees = readdir($open)))
{
if(is_file($map."/".$lees))
{
if($lees != "." && $lees != "..")
{
$filearray['file'][] = $lees;
}
}
}
closedir($open);
return $filearray;
}
$aFiles = checkdir("../upload/".$cat);
?>
<?php
echo "<form method=\"POST\" action=\"\">";
echo "<select name=\"bestand\">";
foreach($aFiles['file'] as $file)
{
echo "<option value=\"".$file."\">".$file."</option>";
}
echo "</select>";
echo "<input type=\"submit\" name=\"verwijder\" value=\"verwijder\"/>";
echo "</form>";
if(isset($_POST['verwijder']))
{
$bestand = $_POST['bestand'];
unlink("../upload/".$cat."/".$bestand);
$delete = "DELETE FROM films WHERE film='".$bestand."' OR thumbnail='".$bestand."'";
mysql_query($delete) or die(mysql_error());
}
?>
<?php
}
?>
<?php $cat = $_GET['c']; function checkdir($map) { while(false != ($lees = readdir($open))) { { if($lees != "." && $lees != "..") { $filearray['file'][] = $lees; } } } return $filearray; } $aFiles = checkdir("../upload/".$cat); ?> <?php echo "<form method=\"POST\" action=\"\">"; echo "<select name=\"bestand\">"; foreach($aFiles['file'] as $file) { echo "<option value=\"".$file."\">".$file."</option>"; } echo "<input type=\"submit\" name=\"verwijder\" value=\"verwijder\"/>"; if(isset($_POST['verwijder'])) { $bestand = $_POST['bestand']; unlink("../upload/".$cat."/".$bestand); $delete = "DELETE FROM films WHERE film='".$bestand."' OR thumbnail='".$bestand."'"; } ?> <?php } ?>
Alvast bedankt:$
|