코맨트에서 파일올리기
질문답변에 올라왔길래 답변하면서 만든겁니다.
basic 스킨을 기준으로 했고 뼈대만 만든거니까 살은 알아서들 붙이세요...
view_comment.skin.php 의 comment form 에 enctype="multipart/form-data" 추가,
적당한 위치에 <input type=file name=comment_file> 추가,
write_comment_update.skin.php 에
<?
if(is_uploaded_file($comment_file)) {
$filename = $_FILES[comment_file][name];
$filesize = $_FILES[comment_file][size];
$dest = "$g4[path]/data/file/$bo_table/".$HTTP_POST_FILES[comment_file][name];
move_uploaded_file($HTTP_POST_FILES[comment_file][tmp_name], "$dest");
$imagesize = @getimagesize($dest);
$sql = " insert into $g4[board_file_table]
set bo_table = '$bo_table',
wr_id = '$comment_id',
bf_no = '0',
bf_source = '$filename',
bf_file = '$filename',
bf_content = '{$bf_content}',
bf_download = 0,
bf_filesize = '$filesize',
bf_width = '{$imagesize[0]}',
bf_height = '{$imagesize[1]}',
bf_type = '{$imagesize[2]}',
bf_datetime = '$g4[time_ymdhis]' ";
sql_query($sql);
}
?>
추가,
view_comment.skin.php 코맨트리스트 코맨트내용 밑에
<? $aaa = get_file($bo_table, $comment_id); echo $aaa[0][view];?>
추가.
이 소스에서는 파일명을 바꾸지 않습니다.
중복을 방지하기 위해 파일명도 변경해야하고,
보안을 위해 파일종류도 체크해야하고
수정이나 삭제시의 처리도 해야합니다.
별로 어려운 작업은 아닐겁니다.
basic 스킨을 기준으로 했고 뼈대만 만든거니까 살은 알아서들 붙이세요...
view_comment.skin.php 의 comment form 에 enctype="multipart/form-data" 추가,
적당한 위치에 <input type=file name=comment_file> 추가,
write_comment_update.skin.php 에
<?
if(is_uploaded_file($comment_file)) {
$filename = $_FILES[comment_file][name];
$filesize = $_FILES[comment_file][size];
$dest = "$g4[path]/data/file/$bo_table/".$HTTP_POST_FILES[comment_file][name];
move_uploaded_file($HTTP_POST_FILES[comment_file][tmp_name], "$dest");
$imagesize = @getimagesize($dest);
$sql = " insert into $g4[board_file_table]
set bo_table = '$bo_table',
wr_id = '$comment_id',
bf_no = '0',
bf_source = '$filename',
bf_file = '$filename',
bf_content = '{$bf_content}',
bf_download = 0,
bf_filesize = '$filesize',
bf_width = '{$imagesize[0]}',
bf_height = '{$imagesize[1]}',
bf_type = '{$imagesize[2]}',
bf_datetime = '$g4[time_ymdhis]' ";
sql_query($sql);
}
?>
추가,
view_comment.skin.php 코맨트리스트 코맨트내용 밑에
<? $aaa = get_file($bo_table, $comment_id); echo $aaa[0][view];?>
추가.
이 소스에서는 파일명을 바꾸지 않습니다.
중복을 방지하기 위해 파일명도 변경해야하고,
보안을 위해 파일종류도 체크해야하고
수정이나 삭제시의 처리도 해야합니다.
별로 어려운 작업은 아닐겁니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 3개
그런데 이곳에 에디터를 적용 할 수 있을까요!!
궁금해서요~