求助,为什么数据库没有记录呢
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"conn.execute strSQL
next
set upload=nothing
response.write "<SCRIPT language=JavaScript>alert('文件上传成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"
图片上传的代码
图片都可以上传到服务器。
但是数据库里,没有这条记录
上传的时候,没有错误显示
可以出现 文件上传成功,返回。
请问高手,这是什么原因呢?
以下是 conn.asp 的连接代码
<%
dim conn
dim connstr
'on error resume next
connstr="DBQ="+server.mappath("../paladin/data/impaladin.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
function CloseConn()
conn.close
set conn=nothing
end function
%>
以下是写如数据库的代码
<%
dim upload,file,formName,formPath,iCount,filename,fileExt,i,ranNum
set upload=new upload_5xSoft '建立上传对象
name=upload.form("name")
zhuanti=upload.form("zhuanti")
formPath="paladin"
photointro=HTMLEncode2(upload.form("photointro"))
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file '列出所有上传了的文件
set file=upload.file(formName) '生成一个文件对象
if file.filesize<0 then
response.redirect "info.asp?info=请选择上传的文件"
response.end
end if
if file.filesize>2000000 then
response.redirect "info.asp?info=文件不得超过2M"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" and fileEXT<>".bmp" then
response.redirect "info.asp?info=只允许上传gif,jPG,png,bmp文件!"
response.end
end if
Dim Jpeg
FilePath=Server.MapPath("../")'设置上传目录位置
FilePath=Req(FilePath &"/"&formPath)
Set Jpeg = Server.CreateObject("Persits.Jpeg")
If -2147221005=Err then
Response.write "没有ASPJPEG组件,或组件授权已到期,请安装!"
Response.End()
End If
ranNum=int(900*rnd)+112
filenamett=file.FileName
filenamet=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt
filename=req(filepath&filenamet)
ranNum=int(312*rnd)+109
filesize=file.filesize
if file.FileSize>0 then '如果 FileSize > 0 说明有文件数据
file.SaveAs filename '保存文件
else
response.redirect "info.asp?info=文件错误!"
response.end
end if
'变更扩展名
Jpeg.Open (filename)
'开始变更所有文件扩展名为jpg
filenamelen=len(filenamet)
filenamelen=filenamelen-4
filenamet1=filenamet
filenamet=left(filenamet,filenamelen)
filenamet=filenamet&".jpg"
'结束文件名变更
'添加水印
Jpeg.Open filename
Jpeg.Canvas.Font.Color = &HA83C3C
Jpeg.Canvas.Font.Family = "宋体" 'family设置字体
Jpeg.Canvas.Font.Bold = false '是否设置成粗体
Jpeg.Canvas.Font.Size = 12 '字体大小
Jpeg.Canvas.Font.Quality = 5'输出质量
Jpeg.Canvas.Print Jpeg.width-104, Jpeg.height-13, "www.2st.name"
Jpeg.Save filename
set file=nothing
'结束水印
'开始缩图
'判断哪边为长边,以长边进行缩放
imgWidth=Jpeg.OriginalWidth
imgHeight=Jpeg.OriginalHeight
if imgWidth>=imgHeight and imgWidth>120 then
Jpeg.Width=150
Jpeg.Height=Jpeg.OriginalHeight/(Jpeg.OriginalWidth/150)
end if
if imgHeight>imgWidth and imgHeight>113 then
Jpeg.Height=113
Jpeg.Width=Jpeg.OriginalWidth/(Jpeg.OriginalHeight/113)
end if
'结束判断
'ImgObj.SaveFile(FilePath & "small_" & filenamet)
'end if
'ImgObj.Free
'Set ImgObj = nothing
Jpeg.Sharpen 1, 130
Jpeg.Save (FilePath & "small_" & filenamet)
'缩图保存完毕
'写入数据库
yy=year(date)
mm=right("00"&month(date),2)
dd=right("00"&day(date),2)
idate=yy & "-" & mm & "-" & dd & " "
xx=right("00"&hour(time),2)
ff=right("00"&minute(time),2)
mm=right("00"&second(time),2)
itime=xx & ":" & ff & ":" & mm
itime=idate&itime
photourlb=formPath & filenamet1
'if imgwidth<320 and imgheight<240 then
photourls=formPath & "small_" & filenamet
'else
'photourls=photourlb
'end if
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
conn.execute strSQL
next
set upload=nothing
response.write "<SCRIPT language=JavaScript>alert('文件上传成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"
function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function
Function Req(Str)
If IsEmpty(Str) Then Exit Function
Str = Lcase(Str)
do
A_len=len(Str)
Str = Replace(Str,Chr(0),"")
Str = Replace(Str,"asp","")
Str = Replace(Str,"asa","")
Str = Replace(Str,"aspx","")
Str = Replace(Str,"cer","")
Str = Replace(Str,"cdx","")
Str = Replace(Str,"htr","")
Str = Replace(Str,"asax","")
Str = Replace(Str,"ascx","")
Str = Replace(Str,"ashx","")
Str = Replace(Str,"asmx","")
Str = Replace(Str,"axd","")
Str = Replace(Str,"vsdiso","")
Str = Replace(Str,"rem","")
Str = Replace(Str,"soap","")
Str = Replace(Str,"config","")
Str = Replace(Str,"cs","")
Str = Replace(Str,"csproj","")
Str = Replace(Str,"vb","")
Str = Replace(Str,"vbproj","")
Str = Replace(Str,"webinfo","")
Str = Replace(Str,"licx","")
Str = Replace(Str,"resx","")
Str = Replace(Str,"resou","")
Str = Replace(Str,"jsp","")
Str = Replace(Str,"php","")
Str = Replace(Str,"cgi","")
str = Replace(str," ","")
str = Replace(str,"%5C","")
str = Replace(str,"%2F","")
str = Replace(str,"asp","")
str = Replace(str,"asa","")
str = Replace(str,"cer","")
str = Replace(str,"cdx","")
str = Replace(str,"mdb","")
str = Replace(str,"hrt","")
str = Replace(str,"aspx","")
str = Replace(str,"php","")
str = Replace(str,"jsp","")
str = Replace(str,"'","")
loop until A_len=len(Str)
Req=Str
End Function
%>
请高手帮忙解决一下。非常感谢!@