|
|
|
รบกวนช่วยเรื่อง โค้ดการอัพโหลดแบบ thaicreate หน่อยครับ ว่าใช้โค้ดแบบไหนครับ |
|
|
|
|
|
|
|
เป็นงานเก่าลองเอาไปปรับดู
upload_file.php
<?PHP
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0020)http://qa.buu.ac.th/ -->
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=windows-874" http-equiv=Content-Type>
<link rel="stylesheet" type="text/css" href="admin_files/style.css">
<link rel="stylesheet" type="text/css" href="admin_files/printstyle.css">
<link rel="stylesheet" type="text/css" href="admin_files/chulastyle.css">
<link rel="stylesheet" type="text/css" href="admin_files/theme.css" >
<META name=GENERATOR content="MSHTML 8.00.6001.18812">
<style type="text/css">
<!--
.style10 {font-size: 14px; color: #0000FF; font-weight: bold; font-family: Tahoma; }
.style11 {font-size: 14px}
.style55 { color: #FF0000;
font-size: 18px;
font-weight: bold;
}
.style6 { font-size: 12pt;
color: #0000FF;
font-weight: bold;
font-family: Tahoma;
}
.style58 {font-size: 16px; color: #000000; font-weight: bold; font-family: Tahoma; }
.style59 {color: #FF0000}
.style60 {color: #FF0000; font-weight: bold; }
body {
background-color: #FFFFFF;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
function Checkdata(){
if(document.placeholder.subject.value == "" ){
alert('กรุณากรอกคำอธิบายไฟล์');
document.placeholder.subject.focus();
return false;
} }
</script>
</HEAD>
<BODY topMargin=0>
<form id='placeholder' name='placeholder' method='post' onSubmit='return Checkdata(this);' enctype='multipart/form-data' action='send_file.php' >
<TABLE class="simply" width="600" >
<TBODY>
<thead>
<th height=10 align=left colspan="2"><span class="style58">Upload File</span></th>
<td width="2"></thead>
<TR>
<TD width="127" height=30> </TD>
<TD width="455"> </TD>
</TR>
<TR>
<TD height=30 colspan="2"> <?PHP echo "บ้าบอ บ้าบอ บ้าบอ"; ?></TD>
</TR>
<TR>
<TD width="127" height=30> </TD>
<TD width="455"> </TD>
</TR>
<TR>
<TD height=30><div align="left"> <span class="style10">คำอธิบายไฟล์</span></div></TD>
<TD height=30 class="style10">
<input name="subject" type="text" id="subject" class="ui-state-focus" size="40"></TD>
</TR>
<TR>
<TD height=30><div align="left"> <span class="style10">เลือกไฟล์</span></div></TD>
<TD height=30 class="style10">
<input name="filUpload" type="file" class="ui-state-highlight" id=" filUpload" size="40"></TD></TR>
<TR>
<TD height=30 class="style10"> </TD>
<TD height=30 class="style10"> </TD>
</TR>
<TR>
<TD height=10 colspan="2"><div align="center"><span class="style55">กรุณาตรวจสอบข้อมูลอีกครั้ง
เพื่อความถูกต้อง</span></div></TD>
</TR>
<TR>
<TD height=10 colspan="2"><div align="center"><span class="style55">- - - </span></div></TD>
</TR>
<TR>
<TD height=10 colspan="2"><div align="center">
<p>
<input type='submit' value='Upload' size='2' style='background-color:#9999FF; color:#000000;' onSubmit='return Checkdata(this)'>
<br>
</p>
</div></TD>
</TR>
</TBODY>
</TABLE>
</form>
</BODY></HTML>
send_file.php
<?PHP
session_start();
if (!isset($_SESSION[loginz])) {
header("Location: ../../index.php");
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0020)http://qa.buu.ac.th/ -->
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=windows-874">
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
</HEAD>
<BODY topMargin=0>
<div align="left"><img src="../../../StudentAffair/SDAS_files/about.png" width="600" height="64"> </div>
<br>
<TABLE border=0 cellSpacing=0 cellPadding=0 width=550 >
<TBODY>
<TR>
<td>
<?PHP
$DateNow=Date("d_m_Y_Hi");
$typenews=$_POST[typenews];
$datenews=$_POST[datenews];
function thaistart1($datenews)
{
$d1 = substr($datenews, 0, 2);
$m1 = substr($datenews, 3, 2);
$y1 = substr($datenews, 6, 4) ;
$y2=$y1- "543";
if ($datenews == "")
{
return "";
} else
{
//return $y1 . "-" . $m1 . "-" . $d1. "" . $h1;
return $y2 . "-" . $m1 . "-" . $d1;
}
}
$start1 = thaistart1($datenews);
$subject=$_POST[subject];
$app=$_POST[app];
include "../con.php";
mysql_connect($host,$user,$pw) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client='tis620'");
mysql_query("SET character_set_connection='tis620'");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");
$sql = "select * from ตาราง where subject='$subject' and typenews='$typenews' and datenews='$datenews' " ;
$result = mysql_query($sql) or die ("การเชื่อมต่อมีปัญหา") ;
if($result) {// ถ้าค้นหาคำที่ต้องการไม่พบ
$num = mysql_num_rows($result) ; // ตรวจสอบจำนวนแถวที่ค้นหา
if($num>0) {
echo "<script>alert ('ข่าวซ้ำ...');history.back();</script>";
}else{
if($_FILES["filUpload"]["name"] != "")
$new_name=$DateNow."_".$_FILES["filUpload"]["name"];
$path= "news/".$new_name;
{if(copy($_FILES['filUpload']['tmp_name'], $path))
{ $tmp_file =$_FILES['filUpload']['tmp_name'];
$fileme =$_FILES['filUpload']['name'];
}
}
if($_FILES["filUpload2"]["name"] != "")
$app_name=$DateNow."_".$_FILES["filUpload2"]["name"];
$path= "news/".$app_name;
{if(copy($_FILES['filUpload2']['tmp_name'], $path))
{
//$tmp_file =$_FILES['filUpload']['tmp_name'];
//$fileme =$_FILES['filUpload']['name'];
}
}
$strSQL = "INSERT INTO news ";
$strSQL .="(typenews ,datenews ,subject ,new_name ,app ,app_name) VALUES ('$typenews','$start1','$subject','$new_name','$app','$app_name')";
$objQuery = mysql_query($strSQL);
echo "<br>";
echo "บันทึกข้อมูลเรียบร้อยแล้ว"; }}
?> <!-- ปิดกึ่งกลาง --><!-- ***********************เมนูขวา******************* -->
<!-- ปิดเมนูขวา --></td></TR></TBODY></TABLE>
</BODY></HTML>
ตารางข้อมูล
-- phpMyAdmin SQL Dump
-- version 2.10.3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 15, 2014 at 04:28 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `db_news`
--
-- --------------------------------------------------------
--
-- Table structure for table `news`
--
CREATE TABLE `news` (
`id` int(11) NOT NULL auto_increment,
`typenews` varchar(15) NOT NULL default '',
`datenews` date NOT NULL,
`subject` text NOT NULL,
`new_name` varchar(255) NOT NULL default '',
`app` varchar(255) NOT NULL,
`app_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `news`
--
ต้องไปปรับเอาเองครับ
|
ประวัติการแก้ไข 2014-05-15 15:29:34 2014-05-15 15:38:21
|
|
|
|
Date :
2014-05-15 15:29:04 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thank you หลายๆครับ คุณ Doctor K
|
|
|
|
|
Date :
2014-05-15 16:40:58 |
By :
dagonov |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ปรับเป็น HTML5 น่าจะได้ลูกเล่นเยอะกว่าเก่า
|
|
|
|
|
Date :
2014-05-15 17:40:13 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|