Unlink function not working

Hello,

I have written some code that displays a list the contents of a directory on the server. The user places a checkmark next to the file(s) to be deleted.
Then when the user clicks the “Delete Selected Files” button my php code (below) loops through an array of the selected files. However, it is not working properly.

I checked the permissions on the folder - rwx rwx rwx.

Any help would be appreciated.

<?php

$iTotal = $_POST[‘Final’];
$sArray = $_POST[‘Files’];
$iTemp = count($sArray);
$sPath = “/bluebusiness/FileUploads/”;

print (“You selected to delete $iTemp File(s)<br><br>”);

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

         if ( $sArray[$iCount] != '')
        {
                print ("$sFile &lt;br&gt;");

                if (is_file("$sFile")) 
               {
                      unlink("$sFile");
                }

         }

     }

}

Where is the bluebusiness folder in relation to the root of the drive it’s on?

I suspect that the following line has the problem:

$sPath  = "/bluebusiness/FileUploads/";

That will mean that the file to be deleted has the total file name: /bluebusiness/FileUploads/[filename]
That’s because the slash at the beginning tells PHP to look at the uppermost directory. That may be the case, but if not try removing the slash or using a path relative to the file you’re in.

Hi…
The actual path I refer to in my code is…:
wp-content/themes/bluebusiness/FileUploads/

I think Jake means you should try making that path relative to the base of your HDD and work down the directory tree from there.

c:/wp-content/themes/bluebusiness/FileUploads/

OR

/wp-content/themes/bluebusiness/FileUploads/

OR

/www/htdocs/wp-content/themes/bluebusiness/FileUploads/

etc

Perhaps check in your httpd error logs for more info too.