Custom Plugin Problem

Hello,

I have created a plugin that displays all the image files in my ‘Uploads’ directory. url: http://eastcoasttechwriter.ca/?page_id=1687
The user can place a checkmark to the far right of any image they wish to delete. This works fine.

When the user clicks the ‘Delete Selected Files’ button, it reads my script
delete.php which isn’t working right. I am not able to open the ‘Uploads’
directory in my code and delete any files. I can’t figure out what I have done wrong.

Perhaps not the most elegant throwing a bunch of "else echo"s into the code but it works. Try

delete.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);

   $iTotal	= $_POST['Final'];
   $sArray	= $_POST['Files'];
   $iTemp	= count($sArray);

   $sPath   = ("Uploads/");
   $sDir    = opendir($sPath) or die("There was problem opening the $sPath directory."); 

   print ("You selected to delete $iTemp  file(s):  <br>");

	if ($iTotal > 0)
	{
		for ($iCount = 0; $iCount < $iTotal; $iCount++)
		{
			$sFile = $sPath . $sArray[$iCount];

			if ( $sArray[$iCount] != '')
			{
				print ("$sFile <br>");

				if (is_file("$sFile")) 
				{
					unlink("$sFile");
				}
				else
				{
					echo $sFile . ' is not a file<br />';
				}
			}
			else
			{
				echo '$sArray[' . $iCount . '] ' . $sArray[$iCount] . '<br />';
			}
		}
	}
	else
	{
		echo '$iTotal ' . $iTotal . '<br />';
	}

	closedir($sDir);   

//   header('Location: http://eastcoasttechwriter.ca/?page_id=1687');
?>