|
|
|
เพิ่มข้อมูล อัพโหลดรูปภาพ แต่รูปภาพมันไม่ยอมเข้าไปในฟอเดอร์ที่เราตั้งไว้อะครับช่วยทีนะครับ |
|
|
|
|
|
|
|
เพิ่มข้อมูล อัพโหลดรูปภาพ แต่รูปภาพมันไม่ยอมเข้าไปในฟอเดอร์ที่เราตั้งไว้อะครับช่วยทีนะครับ
Code
<?php require_once('Connections/work.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
if (isset($_FILES["m_pic"]["name"]))
{
$uploaddir="images/";
$images =$uploaddir.basename($_FILES['images']['name']);
if (move_uploaded_file($_FILES['images']['tmp_name'],$images))
{
$images =$_FILES["images"]["name"]; //Pathfile\
}else{
$m_pic = $m_picoldx;
}
}
$insertSQL = sprintf("INSERT INTO dog (d_id, d_pun, d_name, d_sex, d_bith, d_wight, d_price, d_status, d_pic) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, '$d_pic')",
GetSQLValueString($_POST['d_id'], "int"),
GetSQLValueString($_POST['d_pun'], "text"),
GetSQLValueString($_POST['d_name'], "text"),
GetSQLValueString($_POST['d_sex'], "text"),
GetSQLValueString($_POST['d_bith'], "text"),
GetSQLValueString($_POST['d_wight'], "text"),
GetSQLValueString($_POST['d_price'], "text"),
GetSQLValueString($_POST['d_status'], "text"));
//GetSQLValueString($_POST['d_pic'], "text"))
mysql_select_db($database_work, $work);
$Result1 = mysql_query($insertSQL, $work) or die(mysql_error());
$insertGoTo = "showdog.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>"enctype="multipart/form-data">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">D_pun:</td>
<td><input type="text" name="d_pun" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_name:</td>
<td><input type="text" name="d_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_sex:</td>
<td><input type="text" name="d_sex" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_bith:</td>
<td><input type="text" name="d_bith" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_wight:</td>
<td><input type="text" name="d_wight" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_price:</td>
<td><input type="text" name="d_price" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_status:</td>
<td><input type="text" name="d_status" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_pic:</td>
<td><input type="file" name="d_pic" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="เพิ่มข้อมูล"></td>
</tr>
</table>
<input type="hidden" name="d_id" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
รบกวนหน่อยนะครับ
Tag : PHP
|
|
|
|
|
|
Date :
2012-09-05 23:44:01 |
By :
kupramza |
View :
867 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดนี้ครับ
Code (PHP)
if (move_uploaded_file($_FILES['images']['tmp_name'],"images/".$images))
|
|
|
|
|
Date :
2012-09-06 00:49:18 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|