📄 upload.asp
字号:
<%@ language="vbscript" %>
<!--#include file="conn.asp"-->
<!--#include file="upload_class.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>示例结果</title>
<style type="text/css">
TABLE {border:1px green solid;margin-top:5px;}
TD{border-bottom:1px #dddddd solid;height:20px;padding:3px 0 0 5px;}
.head{background-color:#eeeeee;}
</style>
</head>
<body style="font-size:12px">
<%
Dim Upload,successful,tempCls,image,smallImage
'===============================================================================
set Upload=new AnUpLoad '创建类实例
Upload.SingleSize=200*1024 '设置单个文件最大上传限制,按字节计;默认为不限制
Upload.MaxSize=200*1024 '设置最大上传限制,按字节计;默认为不限制
Upload.Exe="rar|jpg|bmp|gif" '设置合法扩展名,以|分割,忽略大小写
Upload.GetData() '获取并保存数据,必须调用本方法
'===============================================================================
if Upload.Err>0 then '判断错误号,如果myupload.Err<=0表示正常
response.write Upload.Description '如果出现错误,获取错误描述
else
savePath=server.MapPath("pics") '图片保存路径
if upload.Forms("Product_Image")<>"" then
set tempCls=upload.files("Product_Image")
if tempcls.SaveToFile(savePath,0) then image=tempCls.FileName
set tempCls=nothing
end if
if upload.Forms("Product_small_Image")<>"" then
set tempCls=upload.files("Product_small_Image")
if tempcls.SaveToFile(savePath,0) then smallImage=tempCls.FileName
set tempCls=nothing
end if
sql="select * from [product]"
set rs=server.CreateObject("adodb.recordset")
rs.Open sql,conn,1,3
rs.AddNew()
rs("Product_Name")=Upload.Forms("Product_Name")
rs("Product_Price")=Upload.Forms("Product_Price")
rs("Product_Introduce")=Upload.Forms("Product_Introduce")
rs("Product_Image")="pics/" & image
rs("Product_small_Image")="pics/" & smallImage
rs("Product_Date")=now()
rs.Update()
set rs=nothing
if not err then response.Write "成功添加到产品库!<a href=""index.asp"">返回继续添加</a>"
end if
set Upload=nothing '销毁类实例
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -