|
 |
|
รบกวนเรื่องการ upload file ไม่ได้ครับ ช่วยทีรบกวนพี่ๆ PHP Programmer ทุกท่าน |
|
 |
|
|
 |
 |
|
ตอนนี้ติดปัญหาตรงที่ อัพโหลดไม่ได้ ลอง echo ดูค่าก็ไม่มี ผมทำในหน้าเดียวกันน่ะครับ พอดีทำฝังใน joomla มันให้เขียน object เดียวเลยยัดไว้ในไฟล์เดียวแล้วใช้วิธีการเช็คการกดปุ่มเอาแล้วส่งค่าจากฟอร์ม มันไม่ได้อ่ะครับ แล้วมันก็ไม่ copy ไฟล์ไปตามที่ต้องการ เห้อ....
Code (PHP)
//เมื่อกดปุ่ม upload file จะแสดงฟอร์ม เพื่อใช้อัพโหลดไฟล์ขึ้นไปบน server
if($_POST['upload']){
echo'<form action="" method="post">';
echo'Welcome <font color="blue">'.$_SESSION['name'].'</font> to Customer Support ';
echo'<input type="submit" name="create" value="Create Account">';
echo'<input type="submit" name="upload" value=" Upload File ">';
echo'<input type="submit" name="logout" value=" Logout ">';
echo'</form>';
echo'<p>';
echo'<form action="" method="post">';
echo'<table width="100%" align="center">';
echo'<tr>';
echo'<td align="right">File Upload : </td>';
echo'<td><input type="file" name="file_1" ></td>';
echo'</tr>';
echo'<tr>';
echo'<td align="right">File Name(or Description) : </td>';
echo'<td><input type="text" name="file_name" size="50"></td>';
echo'</tr>';
echo'<tr>';
echo'<td align="right">Supplier(?) : </td>';
echo'<td><select name="sup_ID"><option value="">---- Please Select Supplier ----</option>';
echo'<option value="1">KPNS</option>';
echo'</select></td>';
echo'</tr>';
echo'<tr>';
echo'<td align="right">File Type : </td>';
echo'<td><select name="file_type"><option value="">---- Please Select Type ----</option>';
echo'<option value="PO">Purchase Order</option>';
echo'</select></td>';
echo'</tr>';
echo'<tr>';
echo'<td align="right">Upload by : </td>';
echo'<td><input type="text" name="upload_by" value='.$_SESSION['name'].' size="50" disabled></td>';
echo'</tr>';
echo'<tr>';
echo'<td> </td>';
echo'<td><input type="submit" name="import" value="Upload Now!"><input type="reset" name="reset" value=" Clear "></td>';
echo'</tr>';
echo'</table>';
echo'</form>';
}
//ถ้ากดปุ่ม upload now จะแสดงหน้าจอยืนยันข้อมูล ก่อนการ อัพโหลด
if($_POST['import']){
echo $file_temp = $_POST['file_1'];
if(copy($_FILES["file_1"]["tmp_name"],"FileUpload/".$_FILES["file_1"]["name"])){
echo'copied';
}else{
echo'Not complete';
}
$userfile_name = $_FILES["file_1"]['name']; // file name
$userfile_tmp = "FileUpload/".$_FILES["file_1"]['tmp_name']; // actual location
$userfile_size = $_FILES["file_1"]['size']; // file size
$userfile_type = $_FILES["file_1"]['type']; // mime type of file determined by php
$userfile_error = $_FILES["file_1"]['error']; // any error!. get reason here
$date1 = date("Y-m-d H:i:s");
//echo $sql_upload = "insert into asmt_file_upload(FileName,FileType,FileSize,FileExtension,FilePath,FileUploadBy,FileUploadDate,Supplier)
//values('$_POST[file_name]','$_POST[file_type]','$userfile_size','$userfile_type','$userfile_tmp','$_POST[upload_by]','$date1','$_POST['sup_ID']')";
}
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-04-07 16:35:50 |
By :
chubichane |
View :
1459 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่วินครับ เอ่อ...ผมเข้าใจว่าเวลากดปุ่มแล้วมันจะรันที่หน้าเดิมหน่ะครับ เลยไม่ได้ใส่ อีกอย่างผมไม่ค่อยเข้าใจในส่วนของ joomla เพราะมันไม่ได้ลิ้งไปหน้าไฟล์ .php แต่มันไปที่ module มันหน่ะครับ อันนี้ผมก็งงๆๆ แต่ว่าเวลา echo file ที่รับมามันได้หน่ะครับ แต่ว่ามันไม่ยอมเก็บอะ มันอ่านได้แต่ชื่อที่ post มาเท่านั้นเอง รบกวนด้วยครับ
|
 |
 |
 |
 |
Date :
2011-04-07 16:58:35 |
By :
chubichane |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปกติฟอร์มส่งข้อมูล จะส่งข้อมูลประเภท text ได้อย่างเดียว
การระบุ enctype="multipart/form-data" เป็นการอนุญาตให้ฟอร์มส่งข้อมูลได้หลายประเภทพร้อมกัน เช่น ข้อความและรูปภาพ (อัพโหลดรูป)
|
 |
 |
 |
 |
Date :
2011-04-07 17:08:46 |
By :
silasakk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|