[제나플러스] 파일 업로드시 이미지 자동 리사이즈 하기 > 팁앤테크

본문 바로가기
사이트 내 전체검색

팁앤테크

[제나플러스] 파일 업로드시 이미지 자동 리사이즈 하기

페이지 정보

본문

write_update.skin.php

**********************

// 이미지 리사이즈
$data_path = $g4[path]."/data/file/$bo_table";

$sql2=" select * from $g4[board_file_table] where  bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no asc";
$results2 = sql_query($sql2);
for ($d=0; $row2=sql_fetch_array($results2); $d++)  {

if ($_FILES[bf_file][name][$d])
{
$file = $data_path .'/'. $row2[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
break;

$rate = $board[bo_image_width] / $size[0]; // 리사이즈를 원치않으면 여기서부터~~~
$height = (int)($size[1] * $rate);

if ($size[0] > $board[bo_image_width]){

@unlink($data_path.'/'.$row2[bf_file]);
$dst = imagecreatetruecolor($board[bo_image_width], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_image_width], $height, $size[0], $size[1]);
imagejpeg($dst, $data_path.'/'.$row2[bf_file], 100); //혹 업로드 이미지 깨지면 여긴 주석처리하시고 바로 아래 껄 이용하세요..
// imagepng($dst, $data_path.'/'.$row2[bf_file], 100); //주석 해제
chmod($data_path.'/'.$row2[bf_file], 0606);

$temp = getimagesize(addslashes($file));
$filesize = filesize($file);

$sql = " update $g4[board_file_table]
            set bf_filesize = '{$filesize}',
                bf_width = '{$temp[0]}',
                bf_height = '{$temp[1]}'
          where bo_table = '$bo_table'
            and wr_id = '$wr_id'
            and bf_no = '$d' ";
sql_query($sql);
 
} // 리사이즈를 원치않으면 여기까지 삭제 & 주석처리하면 됨.
}
}
}
추천0

댓글목록

등록된 댓글이 없습니다.

Total 825건 9 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 추천 날짜
665 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11580 0 02-20
664 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10431 0 02-20
663 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10866 0 02-10
662 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13554 0 01-28
661 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9906 0 01-28
660 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10257 0 01-25
659 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11635 0 01-23
658 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17090 0 01-05
657 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11181 0 12-19
656 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 12067 0 12-17
655 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17884 0 12-02
654 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17994 0 11-20
653 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 42366 0 11-19
652 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 14093 0 11-17
651 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13851 0 11-17
650 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11401 0 11-07
649 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21527 0 10-24
648 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15503 0 10-22
647 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16786 0 10-07
646 제로쪽지보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10546 0 07-02

검색

회원로그인

회원가입

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
4,440
어제
4,345
최대
6,509
전체
1,064,535
Copyright (c) 株式会社YHPLUS. All rights reserved.