01.
<?
02.
session_start();
03.
if
(
$_SESSION
[
'UserID'
] ==
""
)
04.
{
05.
echo
"Please Login!"
;
06.
exit
();
07.
}
08.
ob_start();
09.
?>
10.
<html>
11.
<head>
12.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
13.
<link rel=
"stylesheet"
href=
"style_uploadfile.css"
type=
"text/css"
/>
14.
<title>123</title>
15.
</head>
16.
<br>
17.
<body>
18.
<style type=
"text/css"
>
19.
20.
* {
21.
margin:0;
22.
padding:0;
23.
font:
"Times New Roman"
, Times, serif;
24.
}
25.
#wrapper{
26.
width:420px;
27.
margin: 200 auto;
28.
padding:20px 20px 20px 20px;
29.
border:20px solid #FF8000;
30.
}
31.
.box1 {
32.
width:430px;
33.
background: url(images/tile2.gif) repeat-y;
34.
position:relative;
35.
}
36.
37.
.box1:before {
38.
content: url(images/top2.gif);
39.
display:block;
40.
}
41.
.box1:after {
42.
content: url(images/bottom2.gif);
43.
display:block;
44.
}
45.
.txt{
46.
padding: 0 10px;
47.
}
48.
49.
</style>
50.
<div id=
"wrapper"
>
51.
<div
class
=
"box1"
>
52.
<p
class
=
"txt"
>
53.
<?
54.
55.
if
(((
$_FILES
[
"fileUpload"
][
"type"
] ==
"image/gif"
)
56.
|| (
$_FILES
[
"fileUpload"
][
"type"
] ==
"image/jpeg"
)
57.
|| (
$_FILES
[
"fileUpload"
][
"type"
] ==
"image/pjpeg"
))
58.
&& (
$_FILES
[
"fileUpload"
][
"size"
] < 1000000))
59.
{
60.
if
(
$_FILES
[
"fileUpload"
][
"error"
] > 0)
61.
{
62.
echo
"Error: "
.
$_FILES
[
"fileUpload"
][
"error"
] .
"<br />"
;
63.
}
64.
else
65.
{
66.
echo
"Upload: "
.
$_FILES
[
"fileUpload"
][
"name"
] .
"<br />"
;
67.
echo
"Type: "
.
$_FILES
[
"fileUpload"
][
"type"
] .
"<br />"
;
68.
echo
"Size: "
. (
$_FILES
[
"fileUpload"
][
"size"
] / 1024) .
" Kb<br />"
;
69.
echo
"Stored in: "
.
$_FILES
[
"fileUpload"
][
"tmp_name"
];
70.
}
71.
if
(move_uploaded_file(
$_FILES
[
"fileUpload"
][
"tmp_name"
],
"myfile/"
.
$_FILES
[
"fileUpload"
][
"name"
]))
72.
73.
74.
75.
76.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"6845"
)
or
die
(
"Error Connect to Database"
);
77.
$objDB
= mysql_select_db(
"dc"
);
78.
mysql_query(
"SET NAMES UTF8"
);
79.
$Date
=
date
(
"d/m/y"
);
80.
$Time
=
date
(
"H:i:s"
);
81.
$strSQL
=
"INSERT INTO files "
;
82.
$strSQL
.=
"(UserID,Name,Date,Time,FilesName,Details,Name_M) VALUES ('"
.
$_POST
[
"UserID"
].
"','"
.
$_POST
[
"txtName"
].
"','$Date','$Time','"
.
$_FILES
[
"fileUpload"
][
"name"
].
"','"
.
$_POST
[
"details"
].
"','"
.
$_POST
[
"Name_M"
].
"')"
;
83.
$objQuery
= mysql_query(
$strSQL
);
84.
85.
}
else
{
86.
echo
"ไฟล์ผิดประเภทหรือมีขนาดใหญ่เกินไป"
;
87.
}
88.
?>
89.
<a href=
"index.php?page=ViewFiles"
> View files</a>
90.
</p>
91.
</div>
92.
</div>