|
 |
|
อยากวิธีการ resize ภาพก่อน แล้ว save ลง ฐานข้อมูล mysql โดย BLOB |
|
 |
|
|
 |
 |
|
ใครพอ มี โค้ดตัวอย่างบ้างมั้ยครัย
|
 |
 |
 |
 |
Date :
2011-01-20 12:53:36 |
By :
oasiis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
copy($photo,"ttt/job/$photo_name");
if ($lastname =="jpg" or $lastname =="jpeg") {
$ori_img = imagecreatefromjpeg($photo);
} else if ($lastname =="png") {
$ori_img = imagecreatefrompng($photo);
} else if ($lastname =="gif") {
$ori_img = imagecreatefromgif($photo);
}
$ori_size = getimagesize($photo);
$ori_w = $ori_size[0];
$ori_h = $ori_size[1];
if ($ori_w>=$ori_h) {
$new_w = 100;
$new_h = round(($new_w/$ori_w) * $ori_h);
} else {
$new_h =100;
$new_w = round(($new_h/$ori_h) * $ori_w);
}
$new_img= imagecreatetruecolor($new_w, $new_h);
imagecopyresized( $new_img, $ori_img,0,0,0,0,$new_w, $new_h,$ori_w,$ori_h);
if ($lastname=="jpg" or $ext =="jpeg") {
imagejpeg($new_img,"ttt/images_small/$photo_name");
} else if ($lastname=="png") {
imagepng($new_img,"ttt/images_small/$photo_name");
} else if ($lastname =="gif") {
imagegif($new_img,"ttt/images_small/$photo_name");
}
imagedestroy($ori_img);
imagedestroy($new_img);
$sqlup= "update tb_application set filen='$photo_name' where num='$no' ";
$result = mysql_query($sqlup) ;
echo"<script> alert('เพิ่มข้อมูลและ Upload รูปภาพ เรียบร้อย');</script>";
} //if lastname
else{
echo"<script> alert('เฉพาะรูปภาพนามสกุล *.gif , *.jpg , *.jpeg เท่านั้น');</script>";
}
include"con_db\close.inc" ;
|
 |
 |
 |
 |
Date :
2011-01-21 16:22:51 |
By :
มั่นเมือง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|