제 스킨에 쓰던 함수입니다.
특정 디렉토리의 파일을 검사하여 생성 시긴으로부터 일정 시간이 지나면 파일을 삭제합니다.
function timeover_file_del($dir,$del_time) {
if (is_dir($dir)) {
$dh = @opendir($dir);
while (false !== ($filename = @readdir($dh))) {
$files[] = $filename;
}
sort($files);
if($files[2]) {
$time2=time();
for ($i=2;$files[$i];$i++){
$ftime=@filemtime($dir.'/'.$files[$i])+$del_time;
if ($ftime<=$time2) {
@unlink($dir.'/'.$files[$i]);
}
}
}
@closedir($dh);
}
}
사용법
timeover_file_del('경로','초단위 시간');
예제
test폴더의 파일들을 검사하여 생성시간으로부터 30초가 지나면 파일을 삭제합니다.
timeover_file_del($g4['path'].'/data/file/'.$bo_table.'/test',30);
특정 디렉토리의 파일을 검사하여 생성 시긴으로부터 일정 시간이 지나면 파일을 삭제합니다.
function timeover_file_del($dir,$del_time) {
if (is_dir($dir)) {
$dh = @opendir($dir);
while (false !== ($filename = @readdir($dh))) {
$files[] = $filename;
}
sort($files);
if($files[2]) {
$time2=time();
for ($i=2;$files[$i];$i++){
$ftime=@filemtime($dir.'/'.$files[$i])+$del_time;
if ($ftime<=$time2) {
@unlink($dir.'/'.$files[$i]);
}
}
}
@closedir($dh);
}
}
사용법
timeover_file_del('경로','초단위 시간');
예제
test폴더의 파일들을 검사하여 생성시간으로부터 30초가 지나면 파일을 삭제합니다.
timeover_file_del($g4['path'].'/data/file/'.$bo_table.'/test',30);
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
댓글 1개
14년 전
감사합니다 ㅎ
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 398 | ||
| 7929 | 9년 전 | 318 | ||
| 7928 | 9년 전 | 407 | ||
| 7927 | 9년 전 | 327 | ||
| 7926 | 9년 전 | 657 | ||
| 7925 | 9년 전 | 341 | ||
| 7924 | 9년 전 | 329 | ||
| 7923 | 9년 전 | 334 | ||
| 7922 | 9년 전 | 369 | ||
| 7921 | 9년 전 | 394 | ||
| 7920 | 9년 전 | 315 | ||
| 7919 | 9년 전 | 330 | ||
| 7918 | 9년 전 | 486 | ||
| 7917 | 9년 전 | 323 | ||
| 7916 | 9년 전 | 399 | ||
| 7915 | 9년 전 | 398 | ||
| 7914 | 9년 전 | 405 | ||
| 7913 | 9년 전 | 561 | ||
| 7912 | 9년 전 | 409 | ||
| 7911 | 9년 전 | 356 | ||
| 7910 | 9년 전 | 399 | ||
| 7909 | 9년 전 | 498 | ||
| 7908 | 9년 전 | 412 | ||
| 7907 | 9년 전 | 359 | ||
| 7906 | 9년 전 | 379 | ||
| 7905 | 9년 전 | 357 | ||
| 7904 | 9년 전 | 344 | ||
| 7903 | 9년 전 | 341 | ||
| 7902 | 9년 전 | 550 | ||
| 7901 |
|
9년 전 | 726 | |
| 7900 | 9년 전 | 572 | ||
| 7899 | 9년 전 | 368 | ||
| 7898 | 9년 전 | 378 | ||
| 7897 | 9년 전 | 330 | ||
| 7896 | 9년 전 | 351 | ||
| 7895 | 9년 전 | 459 | ||
| 7894 | 9년 전 | 379 | ||
| 7893 | 9년 전 | 323 | ||
| 7892 | 9년 전 | 372 | ||
| 7891 | 9년 전 | 753 | ||
| 7890 | 9년 전 | 1188 | ||
| 7889 | 9년 전 | 741 | ||
| 7888 |
limsy1987
|
9년 전 | 541 | |
| 7887 | 9년 전 | 536 | ||
| 7886 | 9년 전 | 422 | ||
| 7885 | 9년 전 | 395 | ||
| 7884 | 9년 전 | 398 | ||
| 7883 | 9년 전 | 394 | ||
| 7882 | 9년 전 | 436 | ||
| 7881 | 9년 전 | 428 | ||
| 7880 | 9년 전 | 549 | ||
| 7879 | 9년 전 | 449 | ||
| 7878 | 9년 전 | 1206 | ||
| 7877 | 9년 전 | 741 | ||
| 7876 | 9년 전 | 471 | ||
| 7875 | 9년 전 | 549 | ||
| 7874 |
|
9년 전 | 798 | |
| 7873 | 9년 전 | 509 | ||
| 7872 | 9년 전 | 665 | ||
| 7871 | 9년 전 | 473 | ||
| 7870 | 9년 전 | 597 | ||
| 7869 | 9년 전 | 423 | ||
| 7868 | 9년 전 | 431 | ||
| 7867 | 9년 전 | 410 | ||
| 7866 | 9년 전 | 477 | ||
| 7865 | 9년 전 | 441 | ||
| 7864 | 9년 전 | 503 | ||
| 7863 | 9년 전 | 500 | ||
| 7862 | 9년 전 | 459 | ||
| 7861 | 9년 전 | 620 | ||
| 7860 | 9년 전 | 609 | ||
| 7859 | 9년 전 | 401 | ||
| 7858 | 9년 전 | 693 | ||
| 7857 | 9년 전 | 1063 | ||
| 7856 | 9년 전 | 510 | ||
| 7855 | 9년 전 | 735 | ||
| 7854 | 9년 전 | 722 | ||
| 7853 | 9년 전 | 571 | ||
| 7852 | 9년 전 | 500 | ||
| 7851 | 9년 전 | 493 | ||
| 7850 | 9년 전 | 577 | ||
| 7849 | 9년 전 | 352 | ||
| 7848 | 9년 전 | 402 | ||
| 7847 | 9년 전 | 640 | ||
| 7846 | 9년 전 | 446 | ||
| 7845 | 9년 전 | 405 | ||
| 7844 | 9년 전 | 386 | ||
| 7843 | 9년 전 | 404 | ||
| 7842 | 9년 전 | 390 | ||
| 7841 | 9년 전 | 374 | ||
| 7840 | 9년 전 | 390 | ||
| 7839 | 9년 전 | 426 | ||
| 7838 | 9년 전 | 507 | ||
| 7837 | 9년 전 | 346 | ||
| 7836 | 9년 전 | 393 | ||
| 7835 | 9년 전 | 463 | ||
| 7834 |
|
9년 전 | 1184 | |
| 7833 | 9년 전 | 413 | ||
| 7832 | 9년 전 | 405 | ||
| 7831 | 9년 전 | 548 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기