This is the PHP code I am using:
<?php
// file name is delete.php
include($_SERVER['DOCUMENT_ROOT']."/clergy/includes/initialize.php");
var_dump($_POST);
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));
}
if(isset($_POST['filenm']))
{
$folder = 'www.recse.org/clergy/documents/';
unlink($folder.$filenm);
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;
chdir('../documents/');
$do = unlink($fileToDel);
if($do=="1"){
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(www.recse.org/clergy/documents/Athletic_Center_data_room.pdf) [function.unlink]: No such file or directory in /homepages/4/d322583329/htdocs/diocese/clergy/documents/delete.php on line 18
If I copy www.recse.org/clergy/documents/Athletic_Center_data_room.pdf 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?