Hi
I am trying to set up a system that will delete a class file that is part of a list of files from a certain folder, when clicking on an icon representing that particular file.
Please look at the list code I am using to display the list plus the icons etc.
<?php include ("header.php");
if ($handle = opendir('Classes/CourseFiles/')) {
while (false !== ($fileName = readdir($handle)))
{
if ($fileName != "." && $filename != ".." && strtolower(substr($fileName, strrpos($fileName, '.') + 1)) == 'htm')
{
$thelist .= '<tr class="List">
<td><a href="classes/CourseFiles/' .$fileName.'"><span class="List">'.$fileName.'</span></a></td>
<td><a href="delete_class_file.php?$fileName" title="Delete ' .$fileName .'"><img src="img/delete-file-icon.png" width="64" height="64" alt="delete this file" border="0" ></a></td>
<td><img src="img/addUser.png" width="64" height="64" title="Add Students" alt="Add Students" border="0"></td>
</tr>';
}
}
closedir($handle);
}
if($fileName == "." || $fileName == ".." || $fileName == "index.php" )
{
continue;
}
?>
The listing process is working ok for me so far, you are welcome to take a peek: Click here
but what would the "delete_class_file.php" look like?
I have this, what you see below, but is not working at all.
<?php
include ('header.php');
$folder = "Classes/CourseFiles";
$fileName= $folder .$fileName;
if(@unlink($fileName))
{
echo "
<div id='maindata_Delete'>
<div align=\"center\">File deleted [<a href='index.php'>Click Here</a>] to delete another file or [<a href='viewFiles.php'>Click Here</a>] to go back to the home page</div>";
}
else
{
echo "
<div id='maindata_Delete'>
<div align=\"center\">File could not be deleted [<a href='viewFiles.php'>Try Again</a>]</div>";
};
include ("footer.php");
?>
Your help is appreciated.
Robert