|
 |
|
ช่วยดู code phpให้หน่อยครับ คือผมสร้าง ให้มัน insert ข้อมูล แต่ผมอยากจะให้มัน เพิ่มรูปภาพได้ด้วย ต้องเขียนยังไงอะ |
|
 |
|
|
 |
 |
|

ช่วยดู code phpให้หน่อยครับ คือผมสร้าง ให้มัน insert ข้อมูล แต่ผมอยากจะให้มัน เพิ่มรูปภาพได้ด้วย ต้องเขียนยังไงอะ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("finaldb");
if($_GET["Action"] == "Save")
{
//*** Insert Question ***//
$strSQL = "INSERT INTO webboardpost";
$strSQL .="(CreateDate,titlePost,detailsPost,namePost) ";
$strSQL .="VALUES ";
$strSQL .="('".date("Y-m-d H:i:s")."','".$_POST["txtQuestion"]."','".$_POST["txtDetails"]."','".$_POST["txtName"]."') ";
$objQuery = mysql_query($strSQL);
header("location:webboardNews.php");
}
?>
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<body>
<form action="newPost.php?Action=Save" method="post" name="frmMain" id="frmMain" enctype="multipart/form-data">
<table width="621" border="1" cellpadding="1" cellspacing="1">
<tr>
<td>Question</td>
<td><input name="txtQuestion" type="text" id="txtQuestion" value="" size="70"></td>
</tr>
<tr>
<td width="78">Details</td>
<td><textarea name="txtDetails" cols="50" rows="5" id="txtDetails"></textarea></td>
</tr>
<tr>
<td width="78">Name</td>
<td width="647"><input name="txtName" type="text" id="txtName" value="" size="50"></td>
</tr>
<tr>
<td>Picture</td>
<td> <input type="file" name=""> </td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="Submit">
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
Tag : PHP, MySQL, CakePHP, Web (ASP.NET)

|
|
 |
 |
 |
 |
Date :
2014-09-19 20:27:06 |
By :
toko2041 |
View :
702 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$book_pic=$_FILES['book_pic']['name'];
$book_tmp=$_FILES['book_pic']['tmp_name'];
copy($book_tmp,"../images/$book_pic");
$sql="INSERT INTO books VALUES('','$_POST[book_title]','$_POST[book_writer]','$_POST[normal_price]','$_POST[sale_price]','$_POST[book_pub]','$_POST[book_content]','$book_pic','$_POST[book_cat]','$_POST[book_stock]','$add_time')";
ประมาณนี้ป่าวคับ การเพิ่มรูปเข้าฐานข้อมูล และ Copy รูปไว้ในโฟล์เดอร์ images
|
 |
 |
 |
 |
Date :
2014-09-20 12:39:13 |
By :
esthook |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|