<?php
if(is_uploaded_file($upload1))
//upload1為上傳圖檔input 欄位內的name""
{
if($_FILES['upload1']!="none") {
//resize 390*250 518×351 2
$uploadedfile = $_FILES['upload1']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newwidth=390 ;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$fnsub=explode(".",$_FILES['upload1']['name']);
if($fnsub[1]!="") {
$fn1="bbs_".date("Ymdhis").".".$fnsub[1];
copy($_FILES['upload1']['tmp_name'],$DOCUMENT_ROOT."/upimg/$fn1");
imagejpeg($tmp,$DOCUMENT_ROOT."/upimg/$fn1",100);
imagedestroy($src);
imagedestroy($tmp);
}
}
}
?>