|
 |
|
วานช่วยที ไม่เข้าใจจริงๆครับ ผมอยากอัพโหลดรูปภาพครั้งเดียวหลายรูปลงฐานข้อมูลอันเดียวกัน ที่มีฟิวต่อกันอะครับ |
|
 |
|
|
 |
 |
|
ยังไงหรอครับ งงง
หมายถึง จะเก็บสองรูปใน Record เดียวกัน แต่คนล่ะ Field หรอครับ
|
 |
 |
 |
 |
Date :
2009-11-23 22:31:08 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับผม คนละฟิว แต่อัพโหลดพร้อมกันนะครับ
|
 |
 |
 |
 |
Date :
2009-11-23 22:34:04 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมใช้ฐานข้อมูล phpmyadminนะครับ
|
 |
 |
 |
 |
Date :
2009-11-23 22:45:14 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ผมบอกว่าดูโค๊ตแล้ว ก้อดูตัวนี่แหละครับ ยังงงอยู่ ไม่รู้ว่าจะบังคับให้ลงในแต่ละฟิวอย่างไร
|
 |
 |
 |
 |
Date :
2009-11-23 22:54:04 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่างอันนี้ จะ insert ชื่อภาพ 2 ภาพ (รูปเดียวกัน) แต่คนละขนาด เก็บไว้ใน Record เดียวกัน แต่คนละ Field
เป๊ะเลยนะครับ แต่ต้องดัดแปรงหน่อย อืมม ไม่ทราบว่าคุณเอ๋อิชิ ลอง รันดู และใช้งานดูหรือยังครับ
ลองแก้ Code ดูครับ
|
 |
 |
 |
 |
Date :
2009-11-23 23:45:19 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
phpUploadResizeToMySQL1.html
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<form name="form1" method="post" action="phpMultiUploadResizeToMySQL2.php" enctype="multipart/form-data">
<input type="file" name="fileUpload[]"><br>
<input type="file" name="fileUpload[]"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
phpUploadResizeToMySQL2.php
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
imagesName = array();
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];
copy($_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);
imagesName[] = "'".$_FILES["fileUpload"]["name"][$i]."'";
}
}
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO files ";
$strSQL .="(photo_font,photo_back ) VALUES (".implode(",",imagesName).")";
$objQuery = mysql_query($strSQL);
?>
<a href="phpMultiUploadResizeToMySQL3.php">View files</a>
</body>
</html>
ลองรันดูก่อนครับ
|
 |
 |
 |
 |
Date :
2009-11-24 03:36:19 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันฟ้อง ซินแทกเออเร่ออะครับ บรรทัดแรก imagesname นั่นแหละครับ
|
 |
 |
 |
 |
Date :
2009-11-25 14:21:40 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
imagesName เปลี่ยนเป้น $imagesName ครับ โทดทีครับ ผมเขียนสดไม่ได้เทส
|
 |
 |
 |
 |
Date :
2009-11-25 17:12:13 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กำลังลองเปลี่ยนแปลงอยู่นะครับถ้าไม่ได้ยังงัยจะมารบกวนอีกทีนะครับ อย่าพึ่งรำคราญก่อนนะครับ
|
 |
 |
 |
 |
Date :
2009-11-25 22:37:35 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาใจช่วย มาอ่านด้วย เลยช่วยขุด 
|
 |
 |
 |
 |
Date :
2009-11-26 01:07:44 |
By :
taiton |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รูปยังไม่ยอมลงในฐานข้อมูลเลยอะครับ มันผิดตรงไหน ไม่ยอมฟ้องอะไรเลย แล้วผมจะรู้ไหมเนี่ย
ตรงที่ติดต่อลงฐานข้อมูล ผมก้อเปลี่ยนแล้วนะ แต่ก้อยังไม่ยอมลงอีก
$objconnect=mysql_connect("localhost","root","1123455") or die ("Error connect to database");
$objDB=mysql_select_db("db_shop");
$strsql="insert into tb_product";
$strsql ="(photo_font,photo_back) values (".implode (",",$imagesName).")";
$objquery=mysql_query($strsql);
|
 |
 |
 |
 |
Date :
2009-11-26 14:35:37 |
By :
jatuphol09 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|