Jump to content


Photo

Adding a Delete All Function


  • Please log in to reply
1 reply to this topic

#1 bizerk

bizerk
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 02 October 2006 - 10:36 PM

Guys what should i do to make a Delete All function. Right now i have a list of all these files uploaded and a link under it saying DELETE FILE and when you click that it unlinks the . I want this to remain but have a new checkbox that says DELETE ALL, and making it unlink ALL files in that specific user directory.

here is the code:
function delete($user_dat, $globalvars)
	{
		$split_imgname = explode('.', $_GET['delete']);
		
		if($split_imgname[1] == null)
		{
			echo "We shall have no directory deleting here.";
			
			$exitp = new template();
			$exitp->exitp($user_dat, $globalvars);
		}
		
		if(unlink($user_dat['usrdir'] . "/" . $_GET['delete']))
		{
			@unlink($user_dat['usrdir'] . "/thumbnails/" . $split_imgname[0] . ".gif");
			
			echo "<i>" . $_GET['delete'] . "</i> has been deleted successfully. ";
			echo 'Click <a href="' . $_SERVER['PHP_SELF'] . '?action=imgdir">here</a> to go back.';
		} else {
			echo "Could not remove the image because of unknown errors. ";
			echo 'Click <a href="' . $_SERVER['PHP_SELF'] . '?action=imgdir">here</a> to go back.';



#2 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 02 October 2006 - 11:35 PM

Do an if to check if the check box is checked, then do a foreach loop to unlink.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users