Jump to content

Recommended Posts

I modified the 1st line and then attempted it and this time I got many more errors, am I missing something?

 

<?
if ($handle = opendir($paththumbs)) {
    while (false !== ($file = readdir($handle))) {
       unlink($file);
    }
    closedir($handle);
}
rmdir($paththumbs);
?>

I don't have another directory within the directory, this is the path below. I basically want to delete the /thumbs folder and anything inside it (there are no folders under /thumbs, only files):

 

$paththumbs = "../photos/".$rowPtFila[date]."/thumbs";

try to echo your files under that dir

 

<?
if ($handle = opendir($paththumbs)) {
    while (false !== ($file = readdir($handle))) {
       if($file  == '.'|| $file  == '..'){echo  'this is not directoty<br/>';}
       else  { echo $file.'<br/>';}
    }
    closedir($handle);
}

?>

 

try and see what it returns

 

or maybe this

<?
if ($handle = opendir($paththumbs)) {
    while (false !== ($file = readdir($handle))) {
       unlink($paththumbs.'/'.$file);
    }
    closedir($handle);
}
rmdir($paththumbs);
?>

Can you elaborate on that a bit more? I'm not sure how to incorporate that into the existing code.

write below set of code replacing <directoryName>  where you are writing your present code.Comment that first and try this two lines of code.

 

$cmd= 'rm -rf <directoryName>' ;

 

This command will delete the directory even if it contains the content in it.

 

exec($cmd);

 

Regards

Got this from http://nz.php.net/unlink

 

function SureRemoveDir($dir, $DeleteMe) {
    if(!$dh = @opendir($dir)) return;
    while (false !== ($obj = readdir($dh))) {
        if($obj=='.' || $obj=='..') continue;
        if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true);
    }

    closedir($dh);
    if ($DeleteMe){
        @rmdir($dir);
    }
}

SureRemoveDir($paththumbs, true) ;

 

Scott.

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.