How to make unlink work

This is the PHP code I am using:

// file name is delete.php

echo '<br /><p>The above is a dump of all variables in POST.</p>';

 if (isset($_POST['submitted'])) { // Handle the form.
	$filenm = $_POST['filenm'];
	echo 'the file to delete is:' . $filenm ;
	$filenm = mysql_real_escape_string (trim($filenm));


            $folder = '';
            echo "The file: ".$filenm." has been deleted.";
        } else {
						echo "No files were deleted.";
				echo '<a href="delete_files.html">Return to file deletion selection page.</a><br /> <a href="/clergy/">Return to Clergy main page.</a>';
echo '<br /><p>second attempt</p><br />';

    $fileToDel = $folder . $filenm;
    $do = unlink($fileToDel);
        echo "The file was deleted successfully.";
    } else { echo "There was an error trying to delete the file."; }

This page gives me an error of:
Warning: unlink( [function.unlink]: No such file or directory in /homepages/4/d322583329/htdocs/diocese/clergy/documents/delete.php on line 18

If I copy and paste into my web browser, I will load the pdf file.

I actually get this error twice. Once on line 18 when I try one method of deleting the file, and a second time on line 30 when I try a different line of code.

What am I doing wrong?

The path that you give to unlink() must be the path on the server’s filesystem, not the URL of the file. In other words, something like /homepages/4/d322583329/htdocs/diocese/clergy/documents/Athletic_Center__data_room.pdf

Well this is a first for me. I have never had to use the server information, but it did the trick.


Now I can finish this off an make it pretty. :slight_smile: