|
 |
|
ต้องการ rename รูปภาพที่ อัพขึ้นมา ต้องใส่ตรงไหนหรือครับ จากลิ้งนี้ |
|
 |
|
|
 |
 |
|
Code (PHP)
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_name = $time().$_FILES["fileUpload"]["name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$new_name);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$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,"MyResize/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
|
 |
 |
 |
 |
Date :
2014-02-07 10:59:26 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ครับ แล้วสามารถใช้กับ png ได้หรือป่าวครับ ผม ต้องแก้ตรงไหน
|
ประวัติการแก้ไข 2014-02-07 11:09:45
 |
 |
 |
 |
Date :
2014-02-07 11:06:29 |
By :
มือใหม่อยากลองดี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คำตอบข้อ 1
$new_name = $time().$_FILES["fileUpload"]["name"]; <-- rename ชื่อไฟล์ที่อัพโหลด
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"]; <-- rename ชื่อไฟล์ที่ทำการ resize
Code (PHP)
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_name = $time().$_FILES["fileUpload"]["name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$new_name);
$width=100; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$typeImg = explode('.',$_FILES["fileUpload"]["tmp_name"]);
$i = count($typeImg)-1;
if($typeImg[$i]=='jpg'){
$images_orig = ImageCreateFromJPEG($images);
} elseif($typeImg[$i]=='gif'){
$images_orig = ImageCreateFromGIF($images);
} elseif($typeImg[$i]=='png'){
$images_orig = ImageCreateFromPNG($images);
}
$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,"MyResize/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
|
ประวัติการแก้ไข 2014-02-07 11:51:26
 |
 |
 |
 |
Date :
2014-02-07 11:50:53 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|