Jump to content

help with unlink( .. )...!


powaz

Recommended Posts

hi i need help with unlink();

 

I need to delete my .jpg files from folder and i'm using: " unlink('files/'.$foto); " as i understand unlink() removes only link but not delete my file ?!

so i need to delete my pictures.jpg files from folder...

 

Please help me...

Link to comment
Share on other sites

PHP.net Manual

unlink — Deletes a file

 

If i understand you correctly you wanted to delete all of your pictures under a certain directory?

 

This will remove all files under the directory and additionally remove the directory if you so require

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

//SureRemoveDir('pathtodirectory', false);
//false indicates that you do not want to delete the directory as well

 

If your after just 1 file?

 

Then the method you used should work.

Link to comment
Share on other sites

maybe i need to close fail like this ?!

$fh = fopen('file/'.$foto, 'w') or die("can't open file");

fclose($fh);

but it's not working ....

or i need to create form to next page, because this file i use in my screen ant it didn't closed?!

Whats the problem !!!!

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.