|
 |
|
โค้ดอัพโหลดไฟล์ลงฐานข้อมูลที่หาจากเว็บตอนเซฟไฟล์จะได้เป็นภาษาต่างดาวค่ะจะแก้ยังไงคะ |
|
 |
|
|
 |
 |
|
โค้ดหน้าแรกค่ะ
ชื่อไฟล์ PageUpload.html
Code (PHP)
<!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 name="form1" method="post" action="PageUpload2.php" enctype="multipart/form-data">
<input type="text" name="t1">อันนี้หัวข้อ<br>
<input type="text" name="t2">อันนี้เนื้อหานะ<br>
<input type="file" name="filUpload"><br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Codeหน้า2
PageUpload2.php
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8"/></head>
<body>
<?
if(copy($_FILES["filUpload"]["tmp_name"],"file/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
$filena = $_FILES["filUpload"]["name"];
$headnews = $_POST["t1"];
$detailn = $_POST["t2"];
$datet = date("Y-m-d");
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("intran");
$strSQL = "INSERT INTO tb_news ";
$strSQL .=" VALUES ('','$headnews','$detailn','$filena','$datet')";
$objQuery = mysql_query($strSQL);
}else{
echo "เฮ้อ";}
?>
<a href="PageUpload3.php">View files</a>
</body>
</html>
หน้า3 ชื่อ PageUpload3.php
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<?
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("intran");
$strSQL = "SELECT * FROM tb_news";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="200" border="1">
<tr>
<th width="50"> <div align="center">Files ID </div></th>
<th width="100"> <div align="center">หัวข้อ</div></th>
<th width="200"> <div align="center">รายละเอียด </div></th>
<th width="150"> <div align="center">ไฟล์</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["id_news"];?></td>
<td><?=$objResult["title_news"];?><?=$objResult["date_news"];?></td>
<td><?=$objResult["detial_news"];?></td>
<td><?=$objResult["file_news"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</body>
</html>
ผลลัพธ์ที่ได้ แสดงออกมาปกติแต่ถ้าดูในโฟลเดอร์ที่ใช้เก็บไฟล์ จะเป็นภาษาต่างด้าวค่ะ
Tag : PHP, MySQL, HTML/CSS

|
ประวัติการแก้ไข 2011-01-18 08:28:31
|
 |
 |
 |
 |
Date :
2011-01-18 08:25:33 |
By :
lainhua |
View :
1034 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไฟล์ เป็น ภาษาไทย หรือ เปล่า ครับ
Code (PHP)
copy($_FILES["filUpload"]["tmp_name"],"file/".iconv('UTF-8','TIS-620',''.$_FILES["filUpload"]["name"].''))
|
ประวัติการแก้ไข 2011-01-18 08:45:53
 |
 |
 |
 |
Date :
2011-01-18 08:45:09 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|