<!--#include file="../include/connect.asp" -->
<!--#include file="uploadfile.asp" -->
<%
Response.Buffer = True
Response.Clear
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<%
Dim RsC
Dim SQLC
lange = uploaddata.Item("largenew").Item("value")
small = uploaddata.Item("smallnew").Item("value")
if lange<>"" Then
bytecount=Request.TotalBytes
filename=uploaddata.Item("largenew").Item("filename")
pos_filebegin=InStrRev(filename,"\")
pos_fileend=Len(filename)
filename_new=Mid(filename,pos_filebegin+1,pos_fileend-pos_filebegin)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set uploadfile=fs.CreateTextFile(Server.Mappath("../images"&"/"&filename_new))
uploadfile.Write uploaddata.Item("largenew").Item("value")------ ตรงนี้มัน บอกว่า Invalid procedure call or argument
Response.write(" Uploads Successfully ")
Response.write("<br> File Name " &filename_new)
SET RsCProduct=Server.CreateObject("ADODB.Recordset")
SQLCProduct="Select * From product Where pro_id="&uploaddata.Item("pid").Item("value")
RsCProduct.Open SQLCProduct, Connect, 1, 3
RsCProduct("pro_name") = filename_new
SET RsC=Server.CreateObject("ADODB.Recordset")
SQLC="Select * From product Where pro_id="& id
RsC.Open SQLC, Connect, 1, 3
RsC("pro_name") = pronew ----------ถ้าไม่ใส่รูปใหม่ จะมาตรงนี้ครับ ตรงนี้มัน บอกว่า Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
sql = "select * from tblgoods Order By g_no"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sql, conn, 1, 3
rs.MoveLast
reclast=CStr(rs("g_no") + 1)
if filename = "" then
On Error Resume Next
rs.addnew
rs("g_no") = reclast
rs("g_id") = gid
rs("g_category") = gcat
rs("g_sid") = gsid
rs("g_norprice") = gnorprice
rs("g_preprice") = gpreprice
rs("g_name") = gname
rs("g_detail") = gdetail
rs("g_warantee") = gwarantee
rs("g_fullname") = gfname
rs("g_type") = gtype
rs("g_picture") = "nopic.gif"
rs.update
if Err.Number = -2147217900 then '¶éÒÃËÑÊÊÔ¹¤éÒ«éÓ ¨Ðà¾ÔèÁäÁèä´é
response.write "<br><br><br><br><br><center><b><font face='MS Sans Serif'>"
response.write "ÃËÑÊÊÔ¹¤éÒ«éÓ !<br><br>-=> <input type='button' value='Back' OnClick='history.go(-1)'> <=-<br>^<br>¤ÅÔê¡»ØèÁ¢éÒ§º¹ à¾×èÍ¡ÅѺä»Ë¹éÒ·Õè¼èÒ¹ÁÒ</font></b></center>"
response.End
else
rs.Close
conn.Close
set rs = Nothing
set conn = Nothing
response.redirect "gadd.asp?cat="&gcat&"&re="&session("sadd")
end if
else
On Error Resume Next
newname = filename
value = UploadRequest.Item("blob").Item("Value")
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(Server.mappath("image/"&gcat&"/"&newname))
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
newfilename=newname
rs.addnew
rs("g_no") = reclast
rs("g_id") = gid
rs("g_category") = gcat
rs("g_sid") = gsid
rs("g_norprice") = gnorprice
rs("g_preprice") = gpreprice
rs("g_name") = gname
rs("g_detail") = gdetail
rs("g_warantee") = gwarantee
rs("g_fullname") = gfname
rs("g_type") = gtype
rs("g_picture") = newfilename
rs.update
response.write Err.Number
if Err.Number = -2147217900 then
response.write reclast &"<br><br><br><br><br><center><b><font face='MS Sans Serif'>"
response.write "ÃËÑÊÊÔ¹¤éÒ«éÓ !<br><br> -=> <input type='button' value='Back' OnClick='history.go(-1)'> <=-<br>^<br>¤ÅÔê¡»ØèÁ¢éÒ§º¹à¾×èÍ¡ÅѺä»Ë¹éÒ·Õè¼èÒ¹ÁÒ</font></b></center>"
response.End
else
rs.Close
conn.Close
set rs = Nothing
set conn = Nothing
end if
end if
%>