dota2怎么轮回饰品:学习ASP遇到困难,高手来帮一下小菜!

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 05:24:29
高手来帮一下小菜!这些代码都是什么意思,请详细说明一下,越详细越好,小菜刚开始学!

<% on Error resume next
response.buffer=true
set upload=new upload_5xSoft
title=upload.form("title")
content=upload.form("content")
pro_name=upload.form("pro_name")
temp=upload.form("temp")
set image=upload.file("img")

imgname1=image.filename

if image.filename<>"" then
imgname=getfilename(image.filename)
image.SaveAs Server.MapPath("img/"&imgname)
end if

if imgname1<>"" then
SQL="insert into product(pro_name,title,content,img,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&imgname&"','"&date&"')"
else
SQL="insert into product(pro_name,title,content,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&date&"')"
end if
con.Execute SQL
function getfilename(imgname)
getfilename=replace(replace(replace(cstr(now)," ",""),"-",""),":","")&radm()&right(imgname,4)
end function
if err.number<>0 then
Response.Write(err.Description)
else
Response.Write("<center>信息已经添加成功!<a href='javascript:close()'>关闭窗口</a></center>")
end if

%>
给小弟添加点注释

这个主要是对类的使用
<%

on Error resume next
response.buffer=true '//-------这句话的意思就是指明输出页面是否被缓冲,当属性值为True时,服务器将不会向客户端发送任何信息,直到所有程序执行完或者遇到
'//-------Response.Flush或 Response.End 语句,才会释放缓冲区的信息

set upload=new upload_5xSoft '//-------这个将类upload_5xSoft进行初始化,创建upload对象
title=upload.form("title") '//-------调用类中的form方法接受前面表单传过来的title值
content=upload.form("content")
pro_name=upload.form("pro_name")
temp=upload.form("temp")
set image=upload.file("img") '//-------生成一个文件对象

imgname1=image.filename

if image.filename<>"" then
imgname=getfilename(image.filename)
image.SaveAs Server.MapPath("img/"&imgname) '''''将文件保存到img目录下,文件名为imgname
end if

if imgname1<>"" then
SQL="insert into product(pro_name,title,content,img,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&imgname&"','"&date&"')"
else
SQL="insert into product(pro_name,title,content,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&date&"')"
end if
con.Execute SQL
function getfilename(imgname)
getfilename=replace(replace(replace(cstr(now)," ",""),"-",""),":","")&radm()&right(imgname,4)
end function
if err.number<>0 then
Response.Write(err.Description)
else
Response.Write("<center>信息已经添加成功!<a href='javascript:close()'>关闭窗口</a></center>")
end if

%>

<% on Error resume next
response.buffer=true ////设置缓存,程序执行完服务器才返回请求
set upload=new upload_5xSoft ///set一个upload_5xSoft 对象
title=upload.form("title")
content=upload.form("content")
pro_name=upload.form("pro_name")
temp=upload.form("temp")
set image=upload.file("img")

imgname1=image.filename

if image.filename<>"" then
imgname=getfilename(image.filename)
image.SaveAs Server.MapPath("img/"&imgname)
end if
///根据条件组织SQL语句
if imgname1<>"" then
SQL="insert into product(pro_name,title,content,img,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&imgname&"','"&date&"')"
else
SQL="insert into product(pro_name,title,content,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&date&"')"
end if
con.Execute SQL //执行
function getfilename(imgname)
getfilename=replace(replace(replace(cstr(now)," ",""),"-",""),":","")&radm()&right(imgname,4)
end function
if err.number<>0 then //错误处理
Response.Write(err.Description)
else
Response.Write("<center>信息已经添加成功!<a href='javascript:close()'>关闭窗口</a></center>")
end if

%>

这是一个上传文件的文件,不太好弄懂,其实你可以直接用

<% on Error resume next ‘是一个错误处理
response.buffer=true ’这个是打开缓存
set upload=new upload_5xSoft ‘定义一个上传组件对像
title=upload.form("title") ’这一段不用说了吧,是取‘值的

content=upload.form("content")
pro_name=upload.form("pro_name")
temp=upload.form("temp")
set image=upload.file("img")

imgname1=image.filename

if image.filename<>"" then
imgname=getfilename(image.filename)
image.SaveAs Server.MapPath("img/"&imgname)
end if

if imgname1<>"" then
SQL="insert into product(pro_name,title,content,img,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&imgname&"','"&date&"')"
else
SQL="insert into product(pro_name,title,content,pub_date)Values('"&pro_name&"','"&title&"','"&content&"','"&date&"')"
end if
con.Execute SQL
function getfilename(imgname)
getfilename=replace(replace(replace(cstr(now)," ",""),"-",""),":","")&radm()&right(imgname,4)
end function
if err.number<>0 then
Response.Write(err.Description)
else
Response.Write("<center>信息已经添加成功!<a href='javascript:close()'>关闭窗口</a></center>")
end if

%> ’上面是一个判断然后执行一条SQL语句