01.
if
(isset(
$_POST
[
'submit'
]))
02.
{
03.
04.
$fileMimes
=
array
(
05.
'text/x-comma-separated-values'
,
06.
'text/comma-separated-values'
,
07.
'application/octet-stream'
,
08.
'application/vnd.ms-excel'
,
09.
'application/x-csv'
,
10.
'text/x-csv'
,
11.
'text/csv'
,
12.
'application/csv'
,
13.
'application/excel'
,
14.
'application/vnd.msexcel'
,
15.
'text/plain'
16.
);
17.
18.
19.
if
(!
empty
(
$_FILES
[
'file'
][
'name'
]) && in_array(
$_FILES
[
'file'
][
'type'
],
$fileMimes
))
20.
{
21.
22.
23.
$csvFile
=
fopen
(
$_FILES
[
'file'
][
'tmp_name'
],
'r'
);
24.
25.
26.
fgetcsv
(
$csvFile
);
27.
28.
29.
while
((
$getData
=
fgetcsv
(
$csvFile
, 10000,
","
)) !== FALSE)
30.
{
31.
32.
$idno
=
$getData
[2];
33.
$name
=
$getData
[3];
34.
$birth
=
$getData
[4];
35.
$tel
=
$getData
[5];
36.
$claim
=
$getData
[6];
37.
$subclaim
=
$getData
[7];
38.
$claimcode
=
$getData
[9];
39.
$datewalk
=
$getData
[15];
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
$strSQL1
= "INSERT INTO AUTHEN (AUNO, AUNAME, AUBIRTH ,
55.
AUTEL ,AUCLAIM ,AUSUBCLAIM ,AUCODE ,AUDATE) VALUES (
'" . $idno . "'
,
56.
'" . $name . "'
,
57.
'" . $birth . "'
,
58.
'" . $tel . "'
,
59.
'" . $claim . "'
,
60.
'" . $subclaim . "'
,
61.
'" . $claimcode . "'
,
62.
'" . $datewalk . "'
)";
63.
64.
$datasearch
= odbc_exec(
$c_odbc
,
$strSQL1
)
or
die
(
"ผิดพลาด ค้นหาไม่ได้"
);
65.
66.
67.
68.
}
69.
70.
71.
fclose(
$csvFile
);
72.
73.
header(
"Location: f16.php"
);
74.
}
75.
else
76.
{
77.
echo
"Please select valid file"
;
78.
}
79.
}