김

코맨트에서 파일올리기

질문답변에 올라왔길래 답변하면서 만든겁니다.
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개

좋은 팁 감사드립니다!!

그런데 이곳에 에디터를 적용 할 수 있을까요!!

궁금해서요~
댓글을 작성하시려면 로그인이 필요합니다.

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
06-12-24 조회 2,568
06-12-23 조회 3,627
06-12-23 조회 3,050
06-12-23 조회 3,401
06-12-23 조회 2,655
06-12-23 조회 4,027
06-12-23 조회 2,587
06-12-23 조회 4,303
06-12-23 조회 5,613
06-12-22 조회 3,497
06-12-22 조회 4,665
06-12-22 조회 7,071
06-12-22 조회 4,735
06-12-21 조회 3,073
06-12-21 조회 3,503
06-12-21 조회 3,481
06-12-20 조회 3,002
06-12-20 조회 4,154
06-12-20 조회 3,497
06-12-20 조회 3,027