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

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

팁앤테크

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

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 60,622회 작성일 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 45건 1 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
45 제로 46078 04-06
44 제로 43273 08-03
43 제로 74598 07-08
42 제로 46268 12-20
41 제로 75594 07-15
40 제로 55519 03-16
39 제로 56980 03-16
38 제로 47631 01-18
37 제로 45111 04-08
36 제로 59565 01-09
35 제로 88306 12-09
34 제로 52096 11-16
33 제로 44760 07-23
32 제로 72783 03-29
31 제로 52572 09-07
열람중 제로 60623 04-20
29 제로 71259 01-24
28 제로 73548 01-24
27 제로 62482 01-23
26 제로 87756 01-15
25 제로 111260 04-07
24 제로 97458 04-07
23 제로 84370 02-19
22 제로 54576 01-05
21 제로 52513 12-18

검색

회원로그인

회원가입

사이트 정보

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

접속자집계

오늘
58,654
어제
129,136
최대
431,155
전체
10,085,906
Copyright (c) 株式会社YHPLUS. All rights reserved.