Jump to content

Deletes all files


brentmoeller

Recommended Posts

when the blow code is ran it produces this warning error

 

Warning: filemtime() [function.filemtime]: stat failed for 048_Baby_Colors.png in /home/public_html/.com/kill.php on line 23

 

 

The code deletes all the files in the directory no matter how many hours or seconds ago they was last modified. could someone help me figure out why?

<?php

$dir = '/home/br/public_html/l.com/dfile';

if ($handle = opendir($dir)) {


    while (false !== ($file = readdir($handle))) {

        if ($file[0] == '.' || is_dir("$dir/$file")) {


            continue;

        }

        if ((time() - filemtime($file)) > ($days * 604800)) {

            unlink("$dir/$file");

        }

    }

    closedir($handle);

}

?>

Link to comment
Share on other sites

Warning: filemtime() [function.filemtime]: stat failed for 048_Baby_Colors.png in /home/public_html/.com/kill.php on line 23

 

This seems to indicate that the system could not find the file that you passed to filemtime(). Since it also shows the filename it was looking for, you can see that there is no directory path specified in the value passed to filemtime(). I think you need to add the directory you are searching to that call:

 

filemtime($dir . '/' . $file)

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.