|
|
|
ขอโค้ด upload รูปภาพ ที่ resize ภาพ ก่อนที่ไฟล์จะเข้าฐานข้อมูลค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
move_uploaded_file($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["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);
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"]."')";
$objQuery = mysql_query($strSQL);
}
?>
Go to : PHP Resize Thumbnails Image and Insert to MySQL
ถ้าเป็น PHP + Access ก็อ่านบทความนี้ครับ
Go to : PHP Microsoft Access : Connect to Microsoft Access Database ภาษา PHP กับฐานข้อมูล Microsoft Access
|
|
|
|
|
Date :
2011-07-13 16:22:06 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|