Here’s the page where I’ve used the code:
[php]<?php
if(isset($_GET[‘delete’]) && $_GET[‘delete’]==‘true’) {
unlink(“img/albumOne/”.$_POST[‘fileToDelete’]);
}
?>
<?php
if ($handle = opendir(“img/albumOne”)) {
while (false !== ($file = readdir($handle)))
{
if ($file != “.” && $file != “…”)
{
$myfile = “img/albumOne/”.$file;
echo “
<a href=“img/albumOne/”.$file.”"><img src=“img/albumOne/”.$file."" width=“100” height=“80”> | ";
echo "<form method=\"post\" name=\"deleteSomething\" action="?><?php echo $_SERVER['PHP_SELF'].'?delete=true';?><?php echo" >
<input type=\"text\" name=\"fileToDelete\" value=".$file." >
<input type=\"submit\" value=\"Delete\"></form>";
}
}
closedir($handle);
}
?>[/php]
I was advised to wrap my unlink in an is_file() condion but they didn’t explain why.
I tried this and got the same error:
[php]is_file(unlink(“img/albumOne/”.$_POST[‘fileToDelete’]));[/php]
Thanks for your help again AnotherWannabe. It is much appreciated. What do you suggest I try. If you could explain any advise your giving me that too would be appreciated. Thanks.