|
|
|
php resize แบบหลาย ๆ รูปในครั้งเดียว ขอตัวอย่าง php resize ด้วยครับ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"][$i];
move_uploaded_file($_FILES["fileUpload"]["tmp_name"][$i],"MyResize/".$_FILES["fileUpload"]["name"][$i]);
$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);
echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"][$i]."')";
$objQuery = mysql_query($strSQL);
}
}
?>
<a href="phpMultiUploadResizeToMySQL3.php">View files</a>
</body>
</html>
Go to : PHP Multiple Upload and Multiple Resize to MySQL
|
|
|
|
|
Date :
2011-05-28 08:14:29 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|