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

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

팁앤테크

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

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 57,743회 작성일 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 779건 11 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
529 제로 62079 06-02
열람중 제로 57744 04-20
527 제로 64949 04-11
526 제로 59392 03-14
525 제로 76280 02-13
524 제로 80023 02-09
523 제로 79258 02-08
522 제로 67515 02-08
521 제로 70373 01-31
520 제로 75808 01-28
519 제로 83877 01-27
518 제로 59712 01-26
517 제로 61750 01-24
516 제로 68546 01-24
515 제로 67250 01-24
514 제로 78219 01-24
513 제로 70997 01-24
512 제로 59582 01-23
511 제로 81819 01-15
510 제로 83903 01-15
509 제로 62376 01-10
508 제로 64314 01-04
507 제로 66677 12-27
506 제로 83095 12-14
505 제로 64503 12-10

검색

회원로그인

회원가입

사이트 정보

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

접속자집계

오늘
24,660
어제
11,101
최대
431,155
전체
6,724,700
Copyright (c) 株式会社YHPLUS. All rights reserved.