|
 |
|
ช่วยแก้ code upload ภาพของ php ให้ด้วยครับลองทำดูแล้วมันไม่เข้า ฐานข้อมูล |
|
 |
|
|
 |
 |
|
ผมลองเอาcode ของอันนี้มาแก้ดูแล้วมันไม่ขึ้นชื่อที่ผมตั้งว่า title_view อะครับ ทำยังไงหรอครับ
code ต้นฉบับ https://www.thaicreate.com/php/php-multiple-upload-create-thumbnails.html
หน้าหนึ่ง
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<form name="form1" method="post" action="2.php" enctype="multipart/form-data">
<label> <br>
</label>
<table width="290" border="0">
<tr>
<td width="136" height="33">จุดจัดแสดง</td>
<td width="144"><input name="title_view" type="text" id="title_view"></td>
</tr>
<tr>
<td colspan="2"><input name="fileUpload" type="file" id="fileUpload"></td>
</tr>
<tr>
<td height="26">
<div align="right">
<input name="btnSubmit" type="submit" value="Submit">
</div></td>
<td><label>
<input name="Reset" type="reset" id="Reset" value="Reset">
</label></td>
</tr>
</table>
<label><br>
<br>
<br>
</label>
<p> </p>
</form>
</body>
</html>
หน้าสอง
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "img_thum_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"imgup/".$_FILES["fileUpload"]["name"]);
$width=200; //*** 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,"imgup/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("adminzoo");
$strSQL = "INSERT INTO view ";
$strSQL .="(img_thum,img_view) VALUES ('".$new_images."','".$_FILES["fileUpload"]["name"]."')";
$objQuery = mysql_query($strSQL);
}
?>
<a href="3.php">View files</a>
</body>
</html>
หน้าสาม
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize to MySQL</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("adminzoo");
$strSQL = " select title_view,img_view,img_thum from view group by title_view, img_view,img_thum order by title_view,img_view,img_thum ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="200" border="1">
<tr>
<th width="150"> <div align="center"> </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<td>
<center><a href="imgup/<?=$objResult["img_view"];?>">
<img src="imgup/<?=$objResult["img_thum"];?>" border="0"></a><br><? echo $objResult["title_view"] ;?></center>
</td>
<?
}
?>
</table>
</tr>
<?
mysql_close($objConnect);
?>
<br>
<a href="1.html">Upload Images</a>
</body>
</html>
Tag : PHP, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2011-04-27 13:06:04 |
By :
alohaukulele |
View :
808 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo ค่าออกมาดูหรือยังครับ ว่าค่ามันออกมาเป็นอะไรอ่าครับ
|
 |
 |
 |
 |
Date :
2011-04-27 13:18:18 |
By :
zimmpooh |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปิดในฐานข้อมูลแล้ว เข้าเฉพาะรูปภาพครับ ส่วนที่เป็น ชื่อรูปที่ตั้งว่า titile_view ไม่เข้าเลยครับ
|
 |
 |
 |
 |
Date :
2011-04-27 13:21:59 |
By :
alohaukulele |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|