|
 |
|
ช่วยดูโค้ดนี้ให้ทีครับเป็นโค้ดอัพโหลดไฟล์ภาพลง MySQL |
|
 |
|
|
 |
 |
|
ช่วยดูโค้ดนี้ให้ทีครับเป็นโค้ดอัพโหลดไฟล์ภาพลง MySQL พออัพโหลดโปรแกรมก็อัพรูปให้นะแต่มันไม่บันทึกชื่อภาพลงใน MysQL อ่ะครับ
Code (PHP)
<?php include"connect.inc";
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"]; //name ในที่นี้หมายถึงอะรัยอ่ะครับ
copy($_FILES["fileUpload"]["tmp_name"],"img/".$_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,"img/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "อัพโหลดภาพสำเร็จ.<br>";
//*** Insert Record ***//
//$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
//$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO durable";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-11-04 11:15:26 |
By :
ratasart |
View :
1009 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค้นในบอร์ดดูนะครับ ผมเห็นคำถามแบบนี้เยอะเลยอ่ะครับ และคำตอบดี ๆ ทั้งนั้นเลย
|
 |
 |
 |
 |
Date :
2009-11-04 11:42:54 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา code form มาดูด้วยก็ดีน่ะครับ 
|
 |
 |
 |
 |
Date :
2009-11-04 11:56:56 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<form action="durable_recieve_2.php" method="post" name="frm" enctype="multipart/form-data">
<table width="476" border="0" cellspacing="2">
<tr>
<td colspan="2" bgcolor="#FF82FF"><strong>ลงทะเบียนเพิ่มครุภัณฑ์</strong></td>
</tr>
<tr>
<td width="222"><div align="right">รูปครุภัณฑ์ :: </div></td>
<td width="238"><label>
<input type="file" name="fileUpload" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#E8E8E8">
<input name="submit" type="submit" value="บันทึกทะเบียนครุภัณฑ์" />
<input name="reset" type="reset" value="ยกเลิก" />
</td>
</tr>
</table>
</form>
|
 |
 |
 |
 |
Date :
2009-11-05 09:09:47 |
By :
ratasart |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code form ครับ
Code (PHP)
<form action="durable_recieve_2.php" method="post" name="frm" enctype="multipart/form-data">
<table width="476" border="0" cellspacing="2">
<tr>
<td colspan="2" bgcolor="#FF82FF"><strong>ลงทะเบียนเพิ่มครุภัณฑ์</strong></td>
</tr>
<tr>
<td width="222"><div align="right">รูปครุภัณฑ์ :: </div></td>
<td width="238"><label>
<input type="file" name="fileUpload" />
</label></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#E8E8E8">
<input name="submit" type="submit" value="บันทึกทะเบียนครุภัณฑ์" />
<input name="reset" type="reset" value="ยกเลิก" />
</td>
</tr>
</table>
</form>
ช่วยดูโค้ดนี้ให้ทีครับเป็นโค้ดอัพโหลดไฟล์ภาพลง MySQL พออัพโหลดโปรแกรมก็อัพรูปให้นะแต่มันไม่บันทึกชื่อภาพลงใน MysQL อ่ะครับ
Code (PHP)
<?php include"connect.inc";
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "Thumbnails_".$_FILES["fileUpload"]["name"]; //name ในที่นี้หมายถึงอะรัยอ่ะครับ
copy($_FILES["fileUpload"]["tmp_name"],"img/".$_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,"img/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "อัพโหลดภาพสำเร็จ.<br>";
//*** Insert Record ***//
//$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
//$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO durable";
$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
|
 |
 |
 |
 |
Date :
2009-11-06 11:07:15 |
By :
ratasart |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|