|
 |
|
ช่วยด้วยครับ ใกล้จะผ่านแล้ว ทำไมผมเอาไฟล์นี้รันใน local ได้อ่ะคับ แต่พอรันในเว็บมันขึ้น error ว่า "แนบไฟล์ไม่ผ่านครับ" |
|
 |
|
|
 |
 |
|
Code (PHP)
if (move_uploaded_file($_FILES['classnotes']['tmp_name'], $target_path .$_FILES['classnotes']['name']. $name . ".pdf"))
ให้ดูตรงนี้น่ะครับ มี error อื่นหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2009-10-25 18:39:42 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลี่ยน permission เป็น 0777 ยังคับ
|
 |
 |
 |
 |
Date :
2009-10-25 19:18:10 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบนี้ถูกหรือป่าวคับคุณวิน ผมลองเปลี่ยนสิทธิ์ตามที่คุณเอี่ยวแล้วนะคับ มันก็ยังขึ้น error เดิมอยู่น่ะคับ ขอบคุณคับ
<?php
include"config.inc.php";
$_POST[target_path] = "../contract/";
if ($_FILES['classnotes']['name'] != ""){
if ($_FILES['classnotes']['type'] != "application/pdf") {
echo "<p>Class notes must be uploaded in PDF format.</p>";
} else {
$_POST[name] = $_POST['tmp_name'];
if (move_uploaded_file($_FILES['classnotes']['tmp_name'], $_POST[target_path].$_FILES['classnotes']['name']. $_POST[name] . ".pdf")){
echo "<p>แนบไฟล์ผ่านครับ</p>";
print_r($_FILE);
$sql="insert into contract_room (contract_room.cID, contract_room.room_no, contract_room.contract, contract_room.date) values ('0','$menu',' ".$_POST[target_path].$_FILES['classnotes']['name']." ','$date')";
mysql_query("set name tis620");
$result = mysql_query($sql);
}
else echo "<p>แนบไฟล์ไม่สำเร็จครับ</p>";
} #endIF
} #endIF
|
 |
 |
 |
 |
Date :
2009-10-25 20:25:39 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยด้วยนะคับ ผมต้องทำยังไงบ้าง รันใน local ก็ได้ปกติอ่ะคับ มีตรงไหนผิดหรือป่าวคับ
|
 |
 |
 |
 |
Date :
2009-10-25 21:37:03 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะติด CHMOD 777 น่ะครับ
|
 |
 |
 |
 |
Date :
2009-10-25 21:40:07 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก็แก้ไฟล์เป็น CHMOD 777 แล้วนะคับ แล้วทำไงดีอ่ะคับ
|
 |
 |
 |
 |
Date :
2009-10-25 21:52:47 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีขึ้น error อะไรเลยหรอ
|
 |
 |
 |
 |
Date :
2009-10-25 21:54:39 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สวัสดีคับคุณ xbeginner01 ก็มีขึ้น error แค่คำว่า "แนบไฟล์ไม่สำเร็จครับ" อย่างเดียวเองครับ
|
 |
 |
 |
 |
Date :
2009-10-25 21:59:39 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่าดีครับ 
ขอดูโค้ด ในฟอร์มหน่อยครับ
|
 |
 |
 |
 |
Date :
2009-10-25 22:05:54 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่คือไฟล์ form คับ
<form action="add_contract.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label for="file" > <span class="style6">ไฟล์เอกสารแนบ :</span>
<input name="MAX_FILE_SIZE" type="hidden" value="300000000" />
<input type ="file" name="classnotes" id="classnotes" />
</label>
<span class="style7">(เฉพาะไฟล์ *.pdf เท่านั้น)</span><br>
<span class="style6">สัญญาการซื้อของห้อง :</span>
<select name="menu" id="menu">
<?
$sql="SELECT* FROM tb_room ";
mysql_query("set name tis620");
$dbquery=mysql_db_query($dbname,$sql);
while($row=mysql_fetch_array($dbquery))
{
?>
<option value="<? echo $row['room_no']; ?>"><? echo $row['room_no']; ?></option>
<?
}
mysql_close();
?>
<option value=" " ><? echo $row['room_no']; ?></option>
</select>
<br>
<span class="style6">ทำสัญญาซื้อวันที่ :</span>
<input name="date" type="text" id="date" size="20" maxlength="30">
<span class="style7">(01/05/2552)</span><br>
<p align="center"><input type="submit" name="Submit" value="-----ตกลง-----">
</p>
</form>
|
 |
 |
 |
 |
Date :
2009-10-25 23:01:50 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
 ไม่เข้าใจเหมือนกันแห่ะ ชื่อไฟล์ก็ถูกแล้ว ถ้าเปลี่ยน permission 777 แล้วก็ไม่น่าจะมีปัญหาแล้วน่ะ
ลองเอาบรรทัดนี้ออกดูน่ะ <input name="MAX_FILE_SIZE" type="hidden" value="300000000" />
ถ้าไม่ได้เปลี่ยนไปใช้ copy() ดูครับ
|
 |
 |
 |
 |
Date :
2009-10-25 23:42:16 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
print_r($_FILES) ออกมาดูครับ
|
 |
 |
 |
 |
Date :
2009-10-26 06:23:06 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ให้ echo print_r($_FILES) ออกมาเหรอครับ
|
 |
 |
 |
 |
Date :
2009-10-26 10:01:08 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถูกครับ เพ่ปลากริมเขาแค่จะดูว่ามีค่าอะไรส่งมาบ้างอ่ะครับ
|
 |
 |
 |
 |
Date :
2009-10-26 10:16:23 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองใช้ echo ทั้ง print_r($_FILES) กับ $sql แล้วก็ไม่เห็นมี error อะไรเลยครับ นอกจากคำว่า "แนบไฟล์ไม่ผ่านครับ" อย่างเดียวเองครับ หรือผมทำผิดหว่า........ช่วยหน่อยนะคับ
|
 |
 |
 |
 |
Date :
2009-10-26 20:43:37 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำยังดีคับ ใกล้จะส่งแล้วคับ T_T
|
 |
 |
 |
 |
Date :
2009-10-26 22:41:54 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองเอาโค้ดของคุณไปทดสอบแล้วน่ะมันก็ไม่มีปัญหาไรเลย
มาลองทดสอบไรง่ายๆก่อนไมครับ ลองอัพโหลดไฟล์หลายประเภทดูครับ ลองไม่ต้องฟิคมันให้อัฟโหลดแต่ pdf หรือลองสร้างโค้ดอีกอันมาเทสดูก่อน
https://www.thaicreate.com/php/php-html-file-field-upload.html
ลองสร้างมาก่อนครับตรวจสอบว่าเครื่องเราสามารถอัพโหลดได้จริงเปล่า
แล้วลอง print_r($_FILES) ออกมาครับ ไม่ต้องใส่ echo ข้างหน้าน่ะ
พยายามแก้ให้เสร็จน่ะครับ   
|
 |
 |
 |
 |
Date :
2009-10-27 00:09:07 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทั้งนามสกุลอื่นๆแล้ว มันก็เตือนว่า Class notes must be uploaded in PDF format คับ
ลองอัพแต่ไฟล์อย่างเดียวมันก็ขึ้นเหมือนเดิมอีก
ส่วน print_r($_FILES) ผมลอง echo มันก็ขึ้นข้อความเดิม แต่ print_r($_FILES) อย่างเดียวผมก็ทำอยู่แล้วนี่คับตรงบรรทัดที่ 12 ในไฟล์ up มันก็ไม่ขึ้น error อะไรนอกจาก "แนบไฟล์ไม่สำเร็จครับ" อย่างเดียวเท่านั้น ไม่ว่าจะแก้อะไรก็ตามคับ
แล้วคุณ xbeginner01 ทำยังไงถึงผ่านอ่ะคับ รันใน host หรือใน local อ่ะคับ ผมรันใน local ก็ผ่านนะคับ
ช่วยด้วยคับบบบบบบบบบบบบบบบ T_T
|
 |
 |
 |
 |
Date :
2009-10-27 08:57:11 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เดาได้เลยว่าไฟล์เกินสองเมก
|
 |
 |
 |
 |
Date :
2009-10-27 09:44:12 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขนาดไฟล์ที่ผมอัพ 7.04kb ครับคุณ PlaKriM
|
 |
 |
 |
 |
Date :
2009-10-27 10:21:52 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำแบบ copy ดูมันอัพไฟล์ได้ แต่จะแทรกลงดาต้าเบสยังไงตรงไหนอ่ะคับ
<?
if(copy($_FILES["filUpload"]["tmp_name"],"../contract/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete";
}
?>
|
 |
 |
 |
 |
Date :
2009-10-27 14:20:37 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วคับ เย้เย้ ปัญหานิดเดียวเองง่ะ ต้องไปเซตค่า chmod ที่โฟล์เดอร์ที่ผมจะอัพด้วยอ่ะคับ มันถึงจะยอมให้อัพได้
สรุปแล้วต้องเซตทั้งโฟล์เดอร์และไฟล์เลยคับ ขอบคุณทุกท่านที่ให้ความช่วยเหลือนะคร้าบบบบ
|
 |
 |
 |
 |
Date :
2009-10-27 22:32:32 |
By :
backship |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลักษณะนี้ปกติจะเกิดกับ os ของ linuxเหรอครับ ผมดูแล้ว ใช้ใน win2003 ไม่เคยเจอครับ
|
 |
 |
 |
 |
Date :
2009-10-28 09:33:57 |
By :
tingtongkub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|