|
|
|
move_uploaded_file uploa fileไม่ไป ต้องการ upload file ไม่ Error ข้อความไป ส่งเข้าฐานข้อมูลสำเร็จ แ |
|
|
|
|
|
|
|
ต้องการ upload file ไม่ Error ข้อความไป ส่งเข้าฐานข้อมูลสำเร็จ แต่จะเอาไฟล์เข้าไปเก็นที่ Server ด้วยครับ แนะนำหน่อย
Code (PHP)
<?ob_start();?>
<?php require_once('Connections/camp.php'); ?>
<?php require_once('css.css'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
//---------------------------------------------------------------------------
$newname = time().$_FILES['fileupload']['tmp_name'];
move_uploaded_file($_FILES['fileupload']['tmp_name'],"myfile/".$newname);
//-------------------------------------------------------------------------------
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO bootcamp (img, name_th, last_th, name_en, last_en, religion, tel, type_food, lose_food, school, area, address, file1, file2, file3, `date`, `time`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($newname, "text"),
GetSQLValueString($_POST['name_th'], "text"),
GetSQLValueString($_POST['last_th'], "text"),
GetSQLValueString($_POST['name_en'], "text"),
GetSQLValueString($_POST['last_en'], "text"),
GetSQLValueString($_POST['religion'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['type_food'], "text"),
GetSQLValueString($_POST['lose_food'], "text"),
GetSQLValueString($_POST['school'], "text"),
GetSQLValueString($_POST['area'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['file1'], "text"),
GetSQLValueString($_POST['file2'], "text"),
GetSQLValueString($_POST['file3'], "text"),
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['time'], "date"));
mysql_select_db($database_camp, $camp);
$Result1 = mysql_query($insertSQL, $camp) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<center><font class="fonttop" color="#FF0000" ><B>Boot Camp Phuket</B></font></center>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table class="font"align="center">
<tr valign="baseline">
<td nowrap align="right">รูป:</td>
<td><input type="file" name="fileupload" value="" size="32"></td>
<td> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Name_th:</td>
<td><input type="text" name="name_th" value="" size="32"></td>
<td>Last_th:</td>
<td><input type="text" name="last_th" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Name_en:</td>
<td><input type="text" name="name_en" value="" size="32"></td>
<td>Last_en:</td>
<td><input type="text" name="last_en" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Religion:</td>
<td><input type="text" name="religion" value="" size="32"></td>
<td>Tel:</td>
<td><input type="text" name="tel" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Type_food:</td>
<td><input type="text" name="type_food" value="" size="32"></td>
<td>Lose_food:</td>
<td><input type="text" name="lose_food" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">School:</td>
<td><input type="text" name="school" value="" size="32"></td>
<td>Area:</td>
<td><input type="text" name="area" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address:</td>
<td><input type="text" name="address" value="" size="32"></td>
<td> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">File1:</td>
<td><input type="file" name="file1" value="" size="32"></td>
<td> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">File2:</td>
<td><input type="file" name="file2" value="" size="32"></td>
<td><input type="hidden" name="date" value="<?php date("Y-m-d");?>" size="32"></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right">File3:</td>
<td><input type="file" name="file3" value="" size="32"></td>
<td><input type="hidden" name="time" value="<?php date("H:i");?>" size="32"></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> </td>
<td><input type="submit" value="สมัคร"></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
Tag : HTML, HTML5, CakePHP, FuelPHP, Windows
|
ประวัติการแก้ไข 2017-06-10 17:59:19
|
|
|
|
|
Date :
2017-06-10 17:53:12 |
By :
lovebel |
View :
1635 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code สั้นๆ จะต้องบทความนี้ครับ
PHP Uploads/Download Files To MySQL Database
|
|
|
|
|
Date :
2017-06-12 09:32:06 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|