2011-01-27 61 views

回答

4

像這樣,例如:

foreach (glob('/path/to/files/*') as $file) { 
    if (is_writable($file) && filesize($file) < (1024 * 10)) { 
     unlink($file); 
    } 
} 
+1

是的,file_exists在這裏是多餘的:) – 2011-01-27 07:41:39

0

希望這可以幫助:

<?php 
    // outputs e.g. somefile.txt: 1024 bytes 

    $filename = 'somefile.txt'; 
    if(filesize($filename) == (10*1024)){ 
    unlink($filename); 
    } 
?> 
相關問題