|
|
|
upload file แล้วชื่อไฟล์ไม่เข้าไปใน db ครับ ชื่อไฟล์ไม่เข้าใน db ครับ แต่ไฟล์เข้าแล้ว รบกวนดู code |
|
|
|
|
|
|
|
<title>test.php</title>
<?
echo "<h3>Upload file...</h3>";
$A = $_POST['title1'];
$name_file = $_POST['file']['name']; <<<$name_file = $_FILE['file']['name'];
$C = $_POST['des'];
echo " Company Name : $A <br>" ;
echo " Description : $C <hr>" ;
$uploadDir = './uploads/';
$uploadfile = $uploadDir . basename($_FILES['file']['name']);
echo "Upload into: $uploadfile";
echo "<br>Filename: ". $_FILES['file']['name'];
echo "<br>Temp: ". $_FILES['file']['tmp_name'];
echo "<br>type: ". $_FILES['file']['type'];
echo "<br>size: ". $_FILES['file']['size'];
echo "<br>error: ". $_FILES['file']['error'];
echo "</hr>";
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "<br>บันทึกข้อมูลเรียบร้อย<br><br>";
} else {
echo "ไม่สามารถอัพโหลดได้ ";
}
$host = "localhost";
$user = "root";
$pass = "secret";
$dbname = "secret";
mysql_connect( $host,$user,$pass) or die ("you can not connect database");
mysql_select_db($dbname) or die("you can not select database");
$sql = "insert into tb_file value (null , '$A' , '$name_file', '$C' )";
$result = mysql_db_query($dbname,$sql);
if($result){
echo "<a href='show.php'>show</a>";
} else {
echo "<h3>Error : ไม่สามารถอัพโหลดได้</h3>";
}
?>
|
|
|
|
|
Date :
27 ก.พ. 2551 15:46:58 |
By :
... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|