웹마스터 팁

원본글 : http://sejin7940.co.kr/index.php?mid=xe_tips&document_srl=102261

 

=================================================

 

게시글을 삭제하면 해당 글 내부에 첨부된 첨부파일이 서버에서 사라지지 않는 버그가 있다 
원인은 실제 파일삭제하는 함수에서, files DB 의 정보를 조회해서 주소를 찾아서 삭제를 하는데.. 
글 삭제할때 deleteFiles 함수에서 DB 를 먼저 삭제해버리고 파일을 삭제하려해서 문제가 생긴다.

글수정->첨부된 파일을 파일삭제 하는 건 잘 되는데 (이건 deleteFile) 함수를 쓰니..
글 삭제시 이 문제가 생긴다. ( 관리자->컨텐츠->파일 에서는 지워진것처럼 나와서 더 문제인듯)

 


modules/file/file.controller.php 에서

 

function deleteFiles  함수에서

 

// Remove from the DB
$args = new stdClass();
$args->upload_target_srl = $upload_target_srl;
$output = executeQuery('file.deleteFiles', $args);
if(!$output->toBool()) return $output;

// Delete the file
$path = array();
$file_count = count($file_list);
for($i=0;$i<$file_count;$i++)
{
 $this->deleteFile($file_list[$i]->file_srl);

 $uploaded_filename = $file_list[$i]->uploaded_filename;
 $path_info = pathinfo($uploaded_filename);
 if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
}

 

를 아래걸로 교체하면 된다

 

// Delete the file
$path = array();
$file_count = count($file_list);
for($i=0;$i<$file_count;$i++)
{
 $this->deleteFile($file_list[$i]->file_srl);

 $uploaded_filename = $file_list[$i]->uploaded_filename;
 $path_info = pathinfo($uploaded_filename);
 if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
}

// Remove from the DB
$args = new stdClass();
$args->upload_target_srl = $upload_target_srl;
$output = executeQuery('file.deleteFiles', $args);
if(!$output->toBool()) return $output;

제목 글쓴이 날짜
수정,삭제 버튼을 "이 게시물을.."에 넣기 [1] hangoon 2008.04.16
텔넷으로 순간 압축풀기/폴더 삭제/폴더파일 압축하기... [5] Crazyhouse.cn 2008.05.19
FTP로 지워지지 않는 파일 삭제방법. [9] pakjce 2008.07.05
[초보팁] 우리말 수정하기(예제: 가입창 이름란 삭제) [3] 블루파티 2008.08.19
IE의 특정 도메인 인터넷 임시 파일 Cache만 삭제하기 [3] NetEagle 2008.10.22
내가 작성 한 글에 대한 일괄 삭제/이동/복사 권한 주기 [2] file 개돌 2009.05.15
까페 아이디 삭제후 동일 아이디로 생성하는 방법 키스메리 2009.05.15
쪽지 답글 보내기 원본 내용 삭제 절망린 2009.06.24
플래너 "한줄공지" 가 삭제되지 않는 경우 의 임시대응법 [2] file Gekkou 2009.10.13
댓글 삭제/수정/답글 시 팝업창으로 띄우기 [22] file 고진감래 2009.10.21
[레드의 태그중급]폼 태그..(이상해져서 삭제하구 다시 적습니다) [3] 레드 2003.01.15
메뉴 추가 삭제 수정시 쓰면 좋을것 같네요 - 출처: http://www.happyscript.com/ [1] 예뜨락 2004.09.17
동적 테이블 (행추가, 특정행 삭제) Juny. 2008.02.20
교육용 방명록 #7 [삭제 버튼을 눌렀을 때 비밀번호를 입력받는 부분입니다.] [5] zero 2000.07.03
교육용 방명록 #8 [delete.php3파일에서 넘겨받은 비밀번호를 검사하여 글을 삭제합니다.] [18] zero 2000.07.03
누구나 만들수있는 게시판 [글삭제, 수정 부분] [4] file Mr. JH 2002.08.21
[동주아빠] PHP 게시판(28강) - 삭제(delete.php) 손병목 2003.01.11
[동주아빠] PHP 게시판(끝.29강) - 삭제(delete_ok.php) [18] 손병목 2003.01.11
서브디렉토리,파일까지 모두 삭제하는 함수. [5] Lepas 2004.08.24
[PHP 동영상강의] 33. 자료를 삭제해보자. [6] 서기 2006.01.12