01.
<html>
02.
<head>
03.
04.
<title>บันทึกรูปภาพ</title>
05.
06.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
07.
<style type=
"text/css"
>
08.
a:link {
09.
text-decoration: none;
10.
}
11.
a:visited {
12.
text-decoration: none;
13.
}
14.
a:hover {
15.
text-decoration: none;
16.
}
17.
a:active {
18.
text-decoration: none;
19.
}
20.
</style>
21.
</head>
22.
<body>
23.
<p>
24.
<?php
25.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"123456"
)
or
die
(
"Error Connect to Database"
);
26.
$objDB
= mysql_select_db(
"project"
);
27.
mysql_query(
"SET character_set_results=utf8"
);
28.
mysql_query(
"SET character_set_client=utf8"
);
29.
mysql_query(
"SET character_set_connection=utf8"
);
30.
31.
32.
for
(
$i
=0;
$i
<=(int)(
$_POST
[
"hdnLine"
]);
$i
++)
33.
{
34.
$Str_file
=
explode
(
"."
,
$_FILES
[
'filUpload'
][
'name'
][
$i
]);
35.
echo
$Str_file
[
'0'
].
"<br>"
;
36.
$newname
=
date
(
"Ymdhm"
).
"-"
.
$i
.
"."
.
$Str_file
[
'1'
];
37.
echo
$newname
.
"<br>"
;
38.
39.
if
(
$_FILES
[
"fileUpload"
][
"name"
][
$i
] !=
""
)
40.
{
41.
if
(move_uploaded_file(
$_FILES
[
"fileUpload"
][
"tmp_name"
][
$i
],
"myfile/"
.
$_FILES
[
"fileUpload"
][
"name"
][
$i
]))
42.
{
43.
}}}
44.
45.
46.
$strSQL
=
"INSERT INTO uploadpic"
;
47.
$strSQL
.=
"(item_id,fac_id,filUpload,filUpload1,filUpload2,filUpload3,filUpload4) VALUES ('"
.
$_POST
[
"item_id"
].
"','"
.
$_POST
[
"fac_id"
].
"','"
.
$_FILES
[
"fileUpload"
][
"name"
][0].
"','"
.
$_FILES
[
"fileUpload"
][
"name"
][1].
"','"
.
$_FILES
[
"fileUpload"
][
"name"
][2].
"','"
.
$_FILES
[
"fileUpload"
][
"name"
][3].
"','"
.
$_FILES
[
"fileUpload"
][
"name"
][4].
"')"
;
48.
$objQuery
= mysql_query(
$strSQL
);
49.
if
(
$objQuery
)
50.
{
51.
echo
"Save Done."
;
52.
}
53.
else
54.
{
55.
echo
"Error Save ["
.
$strSQL
.
"]"
;
56.
}
57.
58.
mysql_close();
59.
60.
?>
61.
62.
บันทึกข้อมูลสำเร็จ รอสักครู่เพื่อกลับสู่หน้าหลัก</a></p>
63.
</body>
64.
</html>