View Single Post
08-29-2006, 01:56 PM
#2
Austin is offline Austin
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 353
iTrader: 5 / 100%
 

Austin is on a distinguished road

Send a message via Skype™ to Austin

  Old

Ok I have a super basic way of doing it. It probably need some error checks and what not but oh well.

I changed up your original script a bit by adding some @ to make it work.

PHP Code:
<?php

$read 
'./view/';
$myDirectory = @opendir($read);
   while(
$entryName = @readdir($myDirectory))
   {
      if (
strtolower(substr($entryName, -3)) == "jpg")
      {
         
$dirArray[]=$entryName;
         echo 
$entryName.'<br />';

         echo 
'<TABLE width=500 align=center BGCOLOR=#CCCCCC>';
            echo 
'<TR><TD align=center valign=center>';
               echo 
'<img src=' .$read.$entryName'> <a href="delete.php?a=' .$entryName'">Delete</a><BR>';
            echo 
'</TD></TR>';
         echo 
'</TABLE>';
       }
   }
   @
closedir($myDirectory);
?>
This is delete.php; It is super simple but it works.
PHP Code:
<?php

    $image 
$_GET['a'];
    
$path "./view/";
    
$imgToDel $path.$image;
    @
unlink($imgToDel);
    echo 
"Image deleted! <a href=''>Go Back</a>";

?>
If you need to know how it works or anymore questions lemme know!