|
 |
|
ใครก็ได้ช่วยบอกทีครับ resize ภาพ นามสกุลอื่นได้ แต่ติด .JPEG อะ |
|
 |
|
|
 |
 |
|
ใครก็ได้ช่วยบอกทีครับ resize ภาพ นามสกุลอื่นได้ แต่ติด .JPEG อะ
โค๊ตครับ
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
include "../../connect.php";
if($_FILES['reweb_photo']['tmp_name']!=''){
$size=getimagesize($_FILES['reweb_photo']['tmp_name']);
if($size[0]>500){
$images=$_FILES["reweb_photo"]["tmp_name"];
// $width = round($height*$size[0]/$size[1]);
$new_images = date("YmdHis")."_".$_FILES["reweb_photo"]["name"];
$width=500; //*** Fix Width & Heigh (Autu caculate) ***//
$size=getimagesize($images);
$type=substr($_FILES['reweb_photo']['name'],-4,4);
$type1=substr($_FILES['reweb_photo']['name'],-5,5);
$height=round($width*$size[1]/$size[0]);
if($type==".jpg" || $type1==".JPG" || $type==".jpeg" || $type1==".JPEG"){
$images_orig=imagecreatefromjpeg($images);
}
else if($type==".png"){
$images_orig=imagecreatefrompng($images);
}
else if($type==".gif" || $type1==".GIF"){
$images_orig=imagecreatefromgif($images);
}
echo $images_orig;
$photoX = imagesx($images_orig);
$photoY = imagesy($images_orig);
$images_fin = imagecreatetruecolor($width,$height);
imagecopyresampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
imagejpeg($images_fin,"image_user/".$new_images);
echo $new_images;
imagedestroy($images_orig);
imagedestroy($images_fin);
$reweb_status="0";
$mysql=mysql_query("INSERT INTO register_webboard (reweb_id,reweb_name,reweb_email,reweb_photo,reweb_user,reweb_pass,reweb_status)VALUES('$reweb_id','$reweb_name','$reweb_email','$new_images','$reweb_user','$reweb_pass','$reweb_status')");
if($mysql){
echo '<script>alert("บันทึกข้อมูลเรียบร้อย")</script>';
}
}else{
$fileName = date("YmdHis")."_".$_FILES["reweb_photo"]["name"];
copy($_FILES["reweb_photo"]["tmp_name"],"image_user/".$fileName);
$reweb_status="0";
$mysql=mysql_query("INSERT INTO register_webboard (reweb_id,reweb_name,reweb_email,reweb_photo,reweb_user,reweb_pass,reweb_status)VALUES('$reweb_id','$reweb_name','$reweb_email','$fileName','$reweb_user','$reweb_pass','$reweb_status')");
if($mysql){
echo '<script>alert("บันทึกข้อมูลเรียบร้อย")</script>';
}
}
}
?>
รูปภาพที่ขึ้น

ขอบคุณครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-02-07 01:18:23 |
By :
ploypetpot |
View :
1061 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 01
|