Jump to content

$_GET from a URL?


LemonInflux

Recommended Posts

  • Replies 103
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

<?php
$dir=opendir($f_user);
while(($file = readdir($dir)) !== false)  
{  
if($file !== '.' && $file !== '..' && !is_dir($file))  
{  
	$files[] = $file;  
}  
}  



closedir($dir);

if (!unlink($file))
  {
  echo ("Error deleting $file");
  }
else
  {
  echo ("Deleted $file");
  }
?>

 

Link to comment
Share on other sites

<?php

$file = $_GET['del'];

$dir = ($f_user);

recursive_delete($dir);

function recursive_delete( $dir )
{
        if (is_dir($dir)) {
           if ($dh = opendir($dir)) {
               while (($file = readdir($dh)) !== false ) {
                        if( $file != "." && $file != ".." )
                        {
                                if( is_dir( $dir . $file ) )
                                {
                                        echo "Entering Directory: $dir$file<br/>";
                                        recursive_delete( $dir . $file . "/" );
                                        echo "Removing Directory: $dir$file<br/><br/>";
                                        rmdir( $dir . $file );
                                }
                                else
                                {
                                        echo "Deleting file: $dir$file<br/>";
                                        unlink( $dir . $file );
                                }
                        }
               }
               closedir($dh);
           }
        }
}

?>

 

 

Try putting

 

 else
                                {
                                        echo "Deleting file: $dir$file<br/>";
                                        unlink( $dir . $file );
                                }

 

 

after closedir;

Link to comment
Share on other sites

my full code for my gallery worth a shot to modify it for urs

 

<?php

if($row['user'] == $_SESSION['username']){
            $query = "DELETE FROM `gallery` WHERE `id`='$id'";
            $result = mysql_query($query);
            unlink("images/user/image/" . $file);
            echo "<center><b>Image Deleted</b></center>";}


?>

Link to comment
Share on other sites

my code now:

 

<?php

$file = $_GET['del'];

$dir = ($f_user);

recursive_delete($dir);

function recursive_delete( $dir )
{
        if (is_dir($dir)) {
           if ($dh = opendir($dir)) {
               while (($file = readdir($dh)) !== false ) {
                        if( $file != "." && $file != ".." )
                        {
                                if( is_dir( $dir . $file ) )
                                {
                                        echo "Entering Directory: $dir/$file<br/>";
                                        recursive_delete( $dir . "/" . $file);

                                }
                                else
                                {
                                        echo "Deleting file: $dir/$file<br/>";
                                        unlink(  $dir . "/" . $file );
                                }
                        }
               }
               closedir($dh);
           } else
                                {
                                        echo "Deleting file: $dir/$file<br/>";
                                        unlink(  $dir . "/" . $file );
                                }
        }
}

?>

Link to comment
Share on other sites

that just makes sure the box is checked :) the following code will make sure if each check box is posted that it will follow out on function recursive delete.

 

 

<?php                        foreach($_POST['del'] as $delete) {

function recursive_delete( $dir )
{
        if (is_dir($dir)) {
           if ($dh = opendir($dir)) {
               while (($file = readdir($dh)) !== false ) {
                        if( $file != "." && $file != ".." )
                        {
                                if( is_dir( $dir . $file ) )
                                {
                                        echo "Entering Directory: $dir$file<br/>";
                                        recursive_delete( $dir . $file . "/" );
                                        echo "Removing Directory: $dir$file<br/><br/>";
                                        rmdir( $dir . $file );
                                }
                                else
                                {
                                        echo "Deleting file: $dir$file<br/>";
                                        unlink( $dir . $file );
                                }
                        }
               }
               closedir($dh);
           }
        }

}
}


    ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.