deleteFileFromServer();
Posted: Tue Mar 14, 2006 12:54 pm
hi all, I was wondering what the easest way to enable a user to remove a file from the server would be? and where I may find an example to get me started?
Thanks
Thanks
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
function deleteFile($filepath) {
return (file_exists($filepath) && unlink($filepath));
}Code: Select all
if (!empty($_GET['filepath']) && deleteFile($_GET['filepath'])) {
echo 'file succesfuly deleted';
}Code: Select all
function deleteFileFromServer($filepath) {
if ($filepath){
// check that the file is within public root folder and not a system file
if(stristr($filepath, $this->fileRoot) === FALSE) {
echo "You do not have permission to remove that file from the server!";
return false;
}elseif (stristr($filepath, $this->fileRoot) === TRUE) {
return (file_exists($filepath) && unlink($filepath));
}else{
echo "Invalid File, Please select another file.";
}
}
}