Hi everyone, I want to delete uploaded files from the server. here I am not using database please check my code and suggest me any changes
Del.php
<?php
$jpgdir = "uploads/";
$file=$_REQUEST['file1'];
echo $file;
//echo $jpgdir;
// Open a known directory, and proceed to read its contents
if (is_dir($jpgdir)) {
if ($dh = opendir($jpgdir)) {
unlink($jpgdir . "/" . $file);
closedir($dh);
}
}
?>
jpgview.php. From this file del.php will be called
<?php
$jpgdir = "uploads/jpg";
$dh = opendir($jpgdir);
echo "JPG FILES";
print("<form name=del action=\"del.php\">");
print("<table border=2>");
while (($file = readdir($dh)) !== false) {
if($file!='.' && $file!='..')
{
print( "<tr><td>");
echo "<A HREF=\"$jpgdir/$file\"><IMG src=\"$jpgdir/$file\"/ height=70 width=70></A><BR>\n";
print("</td><td>");
echo "<input type=\"submit\" name=\"del\" value=\"Delete\" id=\"$file\">";
print("</td></tr>");
}
}
print("</table>");
print("</form>");
closedir($dh);
?>
My problem is I am unable to get the buttons corresponding image name and send it to del.php
Thanx in advance