rendered paste body<?$fulldir=$_SERVER['DOCUMENT_ROOT'].'/gallery/'; function file_delete($file){ global $fulldir; if(file_exists($fulldir.$file){ chmod($fulldir.$file, 0777); unlink($fulldir.$file); }else{ echo $fulldir.$file.' does not exist!'; } }?><html> <head> <title>Sample Directory Read and Delete</title> </head> <body><?if($_GET['v']=='y'){ $selected=$_POST['file'];?> <h1>Delete the file!</h1> <p>Are you sure?</p> <a href="?s=y&file=<?=urlencode($selected)?>">Yes</a> | <a href="?s=n">NO</a><?}elseif($_GET['s']=='y'){ $fileselected=urldecode($_GET['file']); file_delete($fileselected);?> <h1>The file is deleted!</h1> <p><?=$fileselected?> has been deleted<?}else{?> <h1>Grab the contents!</h1> <form action="?v=y" method="post"> <fieldset> <legend>Select a file</legend> <select name="directory><?$dir_handle = @opendir($fulldir);while (false !== ($dr = readdir($dir_handle))) { $chkfl = pathinfo($dr); if($dr!="." && $dr!=".." && $chkfl['extension']!=NULL) { echo '<option value="'.$dr.'">'.$dr.'</option>'; }}closedir($dir_handle);?></select> <input type="submit" value="Delete" /> </fieldset> </form><?}?> </body></html>