Hi,
I'm currently trying to delete a file from a folder however I am getting these errors:
Warning: unlink(testflash.flv) [function.unlink]: No such file or directory in C:\wamp\www\html\delete_video.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\html\delete_video.php:6) in C:\wamp\www\html\delete_video.php on line 8
Would anyone kindly point out where I have made a mistake? Thanks.
view_videos(admin).php:
<?php
$current_dir = "includes/videos/"; // Location to read files from.
$dir = opendir($current_dir); // Opens the directory.
echo ("<p><h1>Video Tutorials:</h1></p><hr><br />");
while ($file = readdir($dir)) // while loop
{
$parts = explode(".", $file); // pull apart the name and dissect by period
if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part
$extension = end($parts); // set to we can see last file extension
if ($extension == "flv"){ // Set allowable file extensions.
echo "<table><tr><td><a href=video_player.php?video=$file> $file </a><br /></td>"; // Link to location of video.
echo "<td><a href=delete_video.php?video=$file> Delete </a><br /></td></tr></table>";
}
}
}
echo "<hr><br />";
closedir($dir); // Close the directory.
?>
</body>
</html>
delete_video.php:
<?php
//delete_video.php
$file = $_GET['video'];
unlink($file);
header("location:view_videos(admin).php");
?>