大家好。这是一个上传图片的ASP文件。请大家帮我看一下
现在的问题是:在lh状态下写入数据库的图片的 imgtype 字段为1而其他的状态默认值为0
可能代码里某个语句未执行。而导致所有上传图片的imgtype默认值都为0 ,所以无法写进。
请各位大侠帮忙看看。。急死我了。。以下是文件代码:
dim rec ,rssoe
dim sql
dim proid
dim userid
dim delid
dim upload,file,formName,formPath,iCount
dim imagename(),imagedesc()
action = request("act")
tp = request("tp")
tel= request("tel")
if tp="lh" then
tpimg = "1"
else
tpimg = "0"
end if
'response.Write tpimg
set rec=server.createobject("adodb.recordset")
if action ="add" then
strdate = date
set upload=new upload_5xSoft ''建立上传对象
if upload.Form("filepath") ="" then ''得到上传目录
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if
iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then '
'如果 FileSize > 0 说明有文件数据
fileurl = formPath&strdate&file.FileName
Response.Write fileurl
file.SaveAs Server.mappath(formPath&strdate&file.FileName) ''保存文件
' response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
' response.write "<center><font color=blue size=2>" & file.FilePath&file.FileName&" ("&file.FileSize&") 文件上传成功<br> 文件名为: </font><font color=green size=3>"& "pic/" &File.FileName&"</font></center><br>"
' response.Write "<center><font color=red size=2>请将上传后的文件名称粘贴到商品图片名称中!</font></center>"
redim preserve imagename(icount+1)
redim preserve imagedesc(icount+1)
imagename(icount) = fileurl
str = "imgdesc" & icount
imagedesc(icount) = upload.form(str)
iCount=iCount+1
end if
set file=nothing
next
sql = "select * from houseimg"
rec.open sql,conn,1,3
for i= 0 to icount -1
rec.AddNew
rec("imgname")= imagename(i)
rec("imgtype")=tpimg
rec("descr")=imagedesc(i)
rec("houseid")=-1
rec("housetel")=tel
rec.Update
next
rec.Close
response.Write tpimg
set rec = nothing
response.Write "<script>alert(""图片上传成功"");location.href=""javascript:history.back(2)"";</script>"
Response.end
end if
set upload=nothing ''删除此对象
%>