 |
|
พี่วิน และทุกคน ช่วยด้วยครับ เพิ่งเขียน asp upload รูปครับ |
|
 |
|
|
 |
 |
|
คือว่าผมต้องการ update ข้อมูล และรูปครับ ทำไงก็ไม่ได้ซะที อยากได้แบบที่ว่า ลบรูปเดิมออกด้วยครับ ช่วยหน่อยน่ะ
<!--#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
uploadfile.Close
set fs=Nothing
id = uploaddata.Item("pid").Item("value")
pronew = uploaddata.Item("pronamenew").Item("value")
descnew = uploaddata.Item("descnew").Item("value")
timenew = uploaddata.Item("timeunitnew").Item("value")
tempnew = uploaddata.Item("tempunitnew").Item("value")
renew = uploaddata.Item("replenunitnew").Item("value")
typenew = uploaddata.Item("typeunitnew").Item("value")
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.
RsC("description") = descnew
RsC("timeunit") = timenew
RsC("tempunit") = tempnew
RsC("replenunit") = renew
RsC("typeunit") = typenew
RsC.Update
RsC.Close
Response.Redirect "product.asp"
%>
</body>
</html
ถ้ามีใครสะดวกที่จะให้ปรึกษา ผ่าน msn ได้ช่วยบอกหน่อยนะครับ แต่อย่าเพิ่งลำคาญละกานน่ะครับ ขอบคุณล่วงหน้า
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
29 ก.ค. 2548 19:04:12 |
By :
อั๋น |
View :
3042 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
'file savegadd.asp นะ
<%
Response.Expires = 0
Response.Buffer = True
Response.Clear
%>
<!--#include file="config.inc" -->
<%
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
gcat = UploadRequest.Item("sltcat").Item("Value")
gid = UploadRequest.Item("txtgid").Item("Value")
gsid = UploadRequest.Item("txtgsid").Item("Value")
gname = UploadRequest.Item("txtgname").Item("Value")
gfname = UploadRequest.Item("txtgfname").Item("Value")
gsize = UploadRequest.Item("txtgsize").Item("Value")
gnorprice = UploadRequest.Item("txtgnorprice").Item("Value")
gpreprice = UploadRequest.Item("txtgpreprice").Item("Value")
gwarantee = UploadRequest.Item("txtgwarantee").Item("Value")
gdetail = UploadRequest.Item("txtgdetail").Item("Value")
gtype = UploadRequest.Item("txtgtype").Item("Value")
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
filename1 = Right(filename,4)
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
%>
ไปแกะโค๊ดเอาเองนะ ผมเองก็ยังงง ๆ อยู่อ่ะ..หวังว่าคงพอจะช่วยได้นะครับ
อ้อ form ที่ส่งค่ามาให้จะต้องเป็นแบบนี้นะครับ
<form name="frmgadd" enctype="multipart/form-data" action="savegadd.asp" method="post">
|
 |
 |
 |
 |
Date :
30 ก.ค. 2548 09:30:26 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
111111
|
 |
 |
 |
 |
Date :
22 พ.ย. 2549 14:15:17 |
By :
11 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Hi! Very nice site! Thanks you very much! YMxeJkslAGS
|
 |
 |
 |
 |
Date :
13 ม.ค. 2550 12:54:37 |
By :
QsdS9TlaYC |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|