This is the code to delete image in a folder...
<?php
$path = "uploads";
if(isset($_POST['file']) && is_array($_POST['file']))
{
foreach($_POST['file'] as $file)
{
unlink($path . "/" . $file) or die("Failed to <strong class='highlight'>delete</strong> file");
}
header("location: " . $_SERVER['REQUEST_URI']); //redirect after deleting files so the user can refresh without that resending post info message
}
?>
<form name="form1" method="post">
<?php
$path = "uploads";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle)))
{
if($file == "index.php")
continue;
if($file == ".")
continue;
if($file == "..")
continue;
echo "<input type='CHECKBOX' name='file[]' value='$file'>";
echo "<img src='$file' alt='$file'><br />";
}
closedir($dir_handle);
?>
<input type="submit" name="Delete" value="Delete">
</form>
For the above code I'm unable to view the image.. any one help me please..