001.
<!--#include file=
"../connect.asp"
-->
002.
<!--#include file=
"upload.asp"
-->
003.
<head>
004.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=tis-620"
>
005.
</head>
006.
<%
007.
len1=Len(request(
"url"
))-InstrRev(request(
"url"
),
"/"
)
008.
pathinfo=Server.mappath(Request.ServerVariables(
"PATH_INFO"
))
009.
pathEnd = Len(pathinfo)-len1
010.
filepath=left(pathinfo,pathEnd) &
"buy/"
011.
012.
Response.Expires=0
013.
Response.Buffer = TRUE
014.
Response.Clear
015.
016.
byteCount = Request.TotalBytes
017.
018.
RequestBin = Request.BinaryRead(byteCount)
019.
Dim
UploadRequest
020.
Set
UploadRequest = CreateObject(
"Scripting.Dictionary"
)
021.
022.
BuildUploadRequest RequestBin
023.
024.
other_name = UploadRequest.Item(
"txtbook"
).Item(
"Value"
)
025.
026.
027.
filepathname = UploadRequest.Item(
"file1"
).Item(
"FileName"
)
028.
029.
if filepathname <>
""
then
030.
filename = lcase(Right(filepathname,Len(filepathname)-InstrRev(filepathname,
"\"
)))
031.
032.
033.
034.
response.write(filepathname &
"<br>"
)
035.
036.
037.
038.
value = UploadRequest.Item(
"file1"
).Item(
"Value"
)
039.
040.
041.
042.
043.
limitSize = 200000 * 1024
044.
if lenB(value) > limitSize then
045.
response.write
"<b>File ใหญ่เกิน "
& _
046.
formatNumber(limitSize / 1024) & _
047.
" kB คลิก Back กลับไปเลือกใหม่"
048.
response.end
049.
end if
050.
if Instr(filename,
".jpg"
)<>0 then
051.
ty=
".jpg"
052.
ElseIf
Instr(filename,
".jpeg"
)<>0
Then
053.
ty=
".jpeg"
054.
ElseIf
Instr(filename,
".gif"
)<>0
Then
055.
ty=
".gif"
056.
ElseIf
Instr(filename,
".png"
)<>0
Then
057.
ty=
".png"
058.
else
059.
%>
060.
<p align=
"center"
><font color=
"#FF0000"
>อนุญาติให้ Upload เฉพาะ .jpg, .jpeg, .gif, .png เท่านั้น</font></p>
061.
<p align=
"center"
><a href=
"javascript:history.back();"
>กลับไปแก้ไข</a></p>
062.
<%
063.
response.end
064.
end if
065.
if lenB(value) = 0 then
066.
%>
067.
<p align=
"center"
><font color=
"#FF0000"
>ไม่มีไฟล์นี้</font></p>
068.
<p align=
"center"
><a href=
"javascript:history.back();"
>กลับไปแก้ไข</a></p>
069.
<%
070.
response.end
071.
end if
072.
073.
Dim
dmyt
074.
dmyt=Day(Now()) &
"-"
& Month(Now()) &
"-"
& Year(Now()) &
"-"
& Hour(Now()) &
"."
& Minute(Now()) &
"."
& Second(Now())
075.
076.
file1=dmyt &
"_"
& filename
077.
078.
Set
ScriptObject = Server.CreateObject(
"Scripting.FileSystemObject"
)
079.
080.
Set
fileObj = ScriptObject.CreateTextFile(filepath & file1)
081.
Dim
i
082.
i=0
083.
For
i = 1 to LenB(value)
084.
fileObj.Write chr(AscB(MidB(value,i,1)))
085.
086.
Next
087.
Session(
"a"
)=file1
088.
fileObj.Close
089.
end if
090.
091.
092.
filepathname2=UploadRequest.Item(
"file2"
).item(
"FileName"
)
093.
094.
if filepathname2 <>
""
then
095.
filename2 = lcase(Right(filepathname2,Len(filepathname2)-InstrRev(filepathname2,
"\"
)))
096.
097.
098.
099.
response.write(filepathname2 &
"<br>"
)
100.
101.
102.
103.
value2 = UploadRequest.Item(
"file2"
).Item(
"Value"
)
104.
105.
106.
107.
108.
limitSize = 200000 * 1024
109.
if lenB(value2) > limitSize then
110.
response.write
"<b>File ใหญ่เกิน "
& _
111.
formatNumber(limitSize / 1024) & _
112.
" kB คลิก Back กลับไปเลือกใหม่"
113.
response.end
114.
end if
115.
if Instr(filename2,
".pdf"
)<>0 then
116.
ty=
".pdf"
117.
ElseIf
Instr(filename2,
".doc"
)<>0
Then
118.
ty=
".doc"
119.
else
120.
%>
121.
<p align=
"center"
><font color=
"#FF0000"
>อนุญาติให้ Upload เฉพาะ .pdf, .doc เท่านั้น</font></p>
122.
<p align=
"center"
><a href=
"javascript:history.back();"
>กลับไปแก้ไข</a></p>
123.
<%
124.
response.end
125.
end if
126.
if lenB(value2) = 0 then
127.
%>
128.
<p align=
"center"
><font color=
"#FF0000"
>ไม่มีไฟล์นี้</font></p>
129.
<p align=
"center"
><a href=
"javascript:history.back();"
>กลับไปแก้ไข</a></p>
130.
<%
131.
response.end
132.
end if
133.
134.
file2=dmyt &
"_"
& filename2
135.
136.
Set
ScriptObject2 = Server.CreateObject(
"Scripting.FileSystemObject"
)
137.
138.
Set
fileObj2 = ScriptObject2.CreateTextFile(filepath & file2)
139.
Dim
j
140.
j=0
141.
For
j = 1 to LenB(value2)
142.
fileObj2.Write chr(AscB(MidB(value,j,1)))
143.
144.
Next
145.
Session(
"b"
)=file2
146.
fileObj2.Close
147.
Else
148.
Session(
"b"
)=
"-"
149.
End
If
150.
151.
152.
Dim
d,sql,rr,s
153.
d=
Date
()
154.
155.
strSQL =
""
156.
strSQL = strSQL &
"INSERT INTO book(bdetail,bpic,bfile,bdate,of_username,statuss) "
157.
strSQL = strSQL &
"VALUES ('"
& other_name &
"','"
& Session(
"a"
) &
"','"
& Session(
"b"
) &
"','"
& d &
"','"
& Session(
"user"
) &
"','0')"
158.
159.
Set
rec = con.Execute(strSQL)
160.
161.
Response.Write (
"<script>window.location='book.asp';</script>"
)
162.
163.
164.
%>