그누보드 업로드 과정이 궁금합니다.
본문
안녕하세요 궁금한 것이 있어 선배님들의 조언을 구합니다.
write_update.php 에서 파일 업로드 부분을 보면 아래 함수를 통해 $tmp_file를 파일 업로드하고,
move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]);
이후에 다시 아래 소스와 같이 DB 업데이트를 합니다.
$sql = " update {$g5['board_file_table']}
set bf_source = '{$upload[$i]['source']}',
bf_file = '{$upload[$i]['file']}',
bf_content = '{$bf_content[$i]}',
bf_fileurl = '{$upload[$i]['fileurl']}',
bf_thumburl = '{$upload[$i]['thumburl']}',
bf_storage = '{$upload[$i]['storage']}',
bf_filesize = '".(int)$upload[$i]['filesize']."',
bf_width = '".$bf_width."',
bf_height = '".$bf_height."',
bf_type = '".$bf_type."',
bf_datetime = '".G5_TIME_YMDHIS."'
where bo_table = '{$bo_table}'
and wr_id = '{$wr_id}'
and bf_no = '{$i}' ";
sql_query($sql);
이렇게 파일 업로드와 DB 업데이트를 따로 하는 이유가 있나요??
문의 드립니다.
답변 2
그누보드의 경우 파일을 업로드 시키면 data폴더에 저장되고
그 파일정보 즉, wr_id , data폴더 내의 파일 위치, 크기, 종류 등등이 DB내 g5_board_file_table에
insert됩니다. update는 파일이 이미 존재하거나 삭제하는 경우에 작동되는거죠.
기본적인 필드는 그냥 최대한 건드리지 않은 범위내에서..
수정되는 부만 update처리하는겂니다.
예를들어 이름이나 순번같은경우는 고정적인부분이다보니.. 이런부분은 제외한거죠.~