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

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

팁앤테크

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

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 57,767회 작성일 12-04-20 11:30

본문

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);
 
} // 리사이즈를 원치않으면 여기까지 삭제 & 주석처리하면 됨.
}
}
}

댓글목록

등록된 댓글이 없습니다.

Total 829건 11 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
579 제로 70152 06-14
578 제로 57690 06-07
577 제로 62117 06-02
열람중 제로 57768 04-20
575 제로 64996 04-11
574 제로 59414 03-14
573 제로 76328 02-13
572 제로 80078 02-09
571 제로 79305 02-08
570 제로 67558 02-08
569 제로 70407 01-31
568 제로 75853 01-28
567 제로 83918 01-27
566 제로 59740 01-26
565 제로 61775 01-24
564 제로 68582 01-24
563 제로 67291 01-24
562 제로 78268 01-24
561 제로 71045 01-24
560 제로 59609 01-23
559 제로 81860 01-15
558 제로 83951 01-15
557 제로 62399 01-10
556 제로 64356 01-04
555 제로 66722 12-27

검색

회원로그인

회원가입

사이트 정보

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

접속자집계

오늘
11,513
어제
25,212
최대
431,155
전체
6,736,765
Copyright (c) 株式会社YHPLUS. All rights reserved.