|
 |
|
เรื่อง คำสั่ง PHP การ upload เมื่อขึ้น server lenux ไม่ทำงานไม่ได้ครับ คิดว่าน่าจะมีปัญหาเรื่อง $_GET $_POST แต่ผมเปลี่ยนไม่ถูกน่ะครับรบกวนช่วยตรวจสอบหน่อยครับ |
|
 |
|
|
 |
 |
|
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>cm2554upload</title>
<link rel="stylesheet" href="../css/style.css" />
</head>
<body>
<?php
@mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("mofintranet");
if($_FILES) {
$num_files = count($_FILES['file']['name']);
for($i = 0; $i < $num_files; $i++) {
if($_FILES['file']['error'][$i] != 0) {
continue;
}
$upfile = $_FILES['file']['tmp_name'][$i];
$file = fopen($upfile, "r");
$content = fread($file, filesize($upfile));
$content = addslashes($content);
fclose($file);
$size = $_FILES['file']['size'][$i];
$name = $_FILES['file']['name'][$i];
$type = $_FILES['file']['type'][$i];
$topic = $_POST['topic'] ;
$sql = "INSERT INTO command2554 VALUES(0, '<ดูคำสั่ง>', '$topic', '$type', '$size','$content');";
$qry = mysql_query($sql);
if(!$qry) {
echo "การบันทึกไฟล์ลำดับที่ " . ($i + 1) . " เกิดข้อผิดพลาด! <br />";
}
else {
echo "การบันทึกไฟล์ลำดับที่ " . ($i + 1) . " เสร็จเรียบร้อย <br />";
}
}
}
?>
<p />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label>
หัวข้อเรื่อง : :
<textarea name="topic" cols="30" rows="5"></textarea>
<br />
<br />
File Upload::
<input name="file[]" type="file" id="file[]" />
<br />
<br />
<input type="submit" name="Submit" value="Upload" />
<br />
<br />
</label>
<H2> <a href="admin.html">>>>>>>ย้อนกลับหน้าหลัก<<<<<</a></H2>
</form><p />
<?php
$result = mysql_query("SELECT * FROM command2554;");
if(!$result || mysql_num_rows($result) == 0) {
echo "ไม่พบไฟล์ในฐานข้อมูล </body></html>";
exit();
}
echo "<table border=1 cellpadding=5 cellspacing=1>
<caption>รายชื่อไฟล์ที่เก็บไว้ในฐานข้อมูล</caption>";
echo "<tr>";
$num_fields = mysql_num_fields($result);
for($i = 0; $i < $num_fields - 2; $i++) {
echo "<th>" . mysql_field_name($result, $i) . "</th>";
}
echo "</tr>";
while($data = mysql_fetch_array($result)) {
echo "<tr valign=top>";
$id = $data[0];
for($i = 0; $i < $num_fields - 2; $i++) {
echo "<td>";
if($i == 1) {
echo "<a href=\"cm2554show_file.php?id=$id\" target=\"_blank\">{$data[$i]}</a>";
}
else {
echo $data[$i];
}
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-05-22 14:42:47 |
By :
vipclubzaa |
View :
1034 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในส่วน ของ user password เข้า database ผมทำการเปลี่ยนเรียบร้อย ครับ ไม่มีฟ้อง error ครับ แต่เมื่อ ทำการ upload งานเข้าไป พบว่า ไม่เข้าไปเก็บใน data base น่ะครับ
ผมทำการเปลี่ยน Chmod 777 แล้วครับ แต่ก็ยังไม่ได้
เลยตรวจสอบ กระทู้เก่า พบว่า อาจจะมีปัญหา ที่ ใส่ code ย่อไม่ได้เนื่องจาก ใช้บน windows สามารถทำงานได้ปกติ แต่ server lenux แล้วไม่ได้ ผมไม่ค่อยเก่งเรื่อง code ครับ ไม่รู้จะต้องเปลี่ยน codeให้สมบูรณ์ตรงไหน
รบกวนอีกครั้งครับ
|
 |
 |
 |
 |
Date :
2012-05-22 14:47:05 |
By :
vipclubzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองหากระทู้ แล้วยังหา ไม่เจอเหมือนกันน่ะคับ
|
 |
 |
 |
 |
Date :
2012-05-23 09:57:19 |
By :
vipclubzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|