Unlink function not working


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.


$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")) 




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.

The actual path I refer to in my code is…:

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.







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