求ASP上传图片到文件夹,保存图片路径到SQL数据库里

2024-11-24 07:27:50
推荐回答(2个)
回答1:

<%
if request.TotalBytes < 1 then
response.Redirect("fabu.asp")
else
str="provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("..\data/feiy.mdb")
set conn=server.CreateObject("adodb.connection")
conn.connectionstring=str
conn.open

aa=request.BinaryRead(request.TotalBytes)
en=chrB(13)&chrB(10)

set st1=server.CreateObject("adodb.stream")
st1.mode=3
st1.type=1
st1.open
st1.write aa

Zf=leftB(aa,clng(instrB(1,aa,en))-1)
a1=instrB(aa,en&en)
a2=instrB(a1,aa,Zf)
a3=midB(aa,a1,a2-a1)
'response.BinaryWrite(a3)
b1=instrB(a2,aa,en&en)
b2=instrB(b1,aa,zf)
b3=midB(aa,b1,b2-b1)
'response.BinaryWrite(b3)
c1=instrB(b2,aa,en&en)
c2=instrB(c1,aa,zf)
c3=midB(aa,c1,c2-c1)
'response.BinaryWrite(c3)
d1=instrB(c2,aa,en&en)
d2=instrB(d1,aa,zf)
d3=midB(aa,d1,d2-d1)
'response.BinaryWrite(d3)
e1=instrB(d2,aa,en&en)
e2=instrB(e1,aa,zf)

wjm=instrB(d2,aa,en&en)
wjm1=midB(aa,d2,wjm-d2)
'response.BinaryWrite(wjm1)

set st2=server.CreateObject("adodb.stream")
st2.mode=3
st2.type=1
st2.open
st1.position=e1+3
st1.copyto st2,e2-e1-6

set sta=server.CreateObject("adodb.stream")
sta.mode=3
sta.type=2
sta.open
sta.writetext a3
sta.position=0
sta.charset="gb2312"
sta.position=6

ma=sta.readtext()

set stb=server.CreateObject("adodb.stream")
stb.mode=3
stb.type=2
stb.open
stb.writetext b3
stb.position=0
stb.charset="gb2312"
stb.position=6

mb=stb.readtext()

set stc=server.CreateObject("adodb.stream")
stc.mode=3
stc.type=2
stc.open
stc.writetext c3
stc.position=0
stc.charset="gb2312"
stc.position=6

mc=stc.readtext()

set std=server.CreateObject("adodb.stream")
std.mode=3
std.type=2
std.open
std.writetext d3
std.position=0
std.charset="gb2312"
std.position=6

md=std.readtext()

set stw=server.CreateObject("adodb.stream")
stw.mode=3
stw.type=2
stw.open
stw.writetext wjm1
stw.position=0
stw.charset="gb2312"
stw.position=6

mw=stw.readtext()

h1=instrrev(mw,".")
h2=instrrev(mw,"""")
h3=mid(mw,h1,h2-h1)

str="provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("..\data/feiy.mdb")
set rev=server.CreateObject("adodb.recordset")
rev.activeconnection=str
rev.open "select * from kuan1",,1,3

if not rev.eof then
'-------------------------------------------------
set rs=conn.execute("select max(myid) as he from kuan1")

st2.savetofile server.MapPath("..\chanp/" & rs("he")+1 & h3)
'hh=st2.size
tumm=rs("he")+1 & h3

conn.execute("insert into kuan1(myid,kh,xl,tu,fl,shuom)values('" & rs("he")+1 & "','" & ma & "','" & mb & "','./chanp/" & tumm & "','" & mc & "','" & md & "')")
'--------------------------------
else
set rs=conn.execute("select max(myid) as he from kuan1")

st2.savetofile server.MapPath("..\chanp/" & 1 & h3)
'hh=st2.size
tumm=1 & h3

conn.execute("insert into kuan1(myid,kh,xl,tu,fl,shuom)values('" & 1 & "','" & ma & "','" & mb & "','./chanp/" & tumm & "','" & mc & "','" & md & "')")
end if
rev.close
rs.close
st1.close
st2.close
sta.close
stb.close
stc.close
std.close
stw.close
conn.close
set st1=nothing
set st2=nothing
set sta=nothing
set stb=nothing
set stc=nothing
set std=nothing
set stw=nothing
set conn=nothing
set rev=nothing
end if
response.write("发布成功!")
%>
SQL把这句改了 没什么区别
str="provider=SQLOLEDB;data source=ds(数据库头(local))initial catalog=db(数据库名字);user id=账号;password=密码;"

自己写的可能有点乱 不过可以上传 关键你可以知道怎么上传了

回答2:

给你发个