|
 |
|
ช่วยดู Code ให้ด้วยคะ ไฟล์ไม่เข้าโฟเดอร์และไม่ลงฐานข้อมูลด้วย |
|
 |
|
|
 |
 |
|
upload.php
<?php
$number_of_file_fields = 0;
$number_of_uploaded_files = 0;
$number_of_moved_files = 0;
$uploaded_files = array();
$upload_directory = dirname(__file__) . '/FileUpload/';
for ($i = 0; $i < count($_FILES['userfile']['name']); $i++) {
$number_of_file_fields++;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'][$i])) {
$number_of_uploaded_files++;
$uploaded_files[$i] = iconv("UTF-8", "TIS-620", $HTTP_POST_FILES['userfile']['name'][$i]);
$fileRand = '';
for($i = 0; $i < 5; $i++) {
$fileRand .= chr(rand(97, 122));
}
$uploaded_files[] = $fileRand.date("YmdHis").$_FILES['userfile']['name'][$i];
copy($HTTP_POST_FILES['userfile']['tmp_name'][$i], $upload_directory.$uploaded_files[$i]);
$number_of_moved_files++;
}
}
echo "Number of File fields created $number_of_file_fields.<br/> ";
echo "Number of files submitted $number_of_uploaded_files . <br/>";
echo "Number of successfully moved files $number_of_moved_files . <br/>";
echo "File Names are <br/>" . implode(',', $uploaded_files);
?>
save.php
$date = date("Y-m-d H:i:s");
$strSQL = "INSERT INTO shareDiscus (Department,Subject,Recipients,Detail,Createby,Modified,FilesName)
VALUES('".$_POST[txtDepartment]."','".$_POST[txtTitle]."','".$_POST[txtRecipient]."','".$_POST[txtDetail]."','$Fname $Lname','$date','$uploaded_files[$i]')";
$objQuery = mysql_query($strSQL) or die(mysql_error());
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-07-11 15:49:52 |
By :
chokul |
View :
17739 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 04
|