图片上传功能模块与其它网站的融合实训Word文件下载.docx
- 文档编号:16671767
- 上传时间:2022-11-25
- 格式:DOCX
- 页数:6
- 大小:17.33KB
图片上传功能模块与其它网站的融合实训Word文件下载.docx
《图片上传功能模块与其它网站的融合实训Word文件下载.docx》由会员分享,可在线阅读,更多相关《图片上传功能模块与其它网站的融合实训Word文件下载.docx(6页珍藏版)》请在冰豆网上搜索。
-->
2)设置上传的文件夹名formpath="
uploadfile/"
uploadfile/可以根据爱好等进行修改成,一旦这样设置,需要在babyadmin\goods\文件夹下创建uploadfile文件夹。
3)增加picname=up_pic()'
调用up_pic()函数,返回文件名
再把所有类似pname=request.form("
pname"
)改为pname=upload.form("
)
4)修改后的goodsadd.asp的代码视图如下:
conn.asp"
-->
%
'
管理员身份验证
ifnot(session("
key"
)="
sa"
orsession("
bd"
bs"
bj"
bc"
)then
response.redirect"
../index.asp"
response.end
endif
%>
这是处理提交过来的数据的页面
formpath="
'
设置上传的文件夹名
url="
index.asp"
上传完后,返回到的页面。
setupload=newupload_5xsoft'
实例化一个上传对象upload,这个无组件上传类最大只能上200K的文件,上传超过200K文件,将会非常的慢,如果想上传更大的文件,可以使用有组件上传
functionup_pic()'
这是一个上传函数
iCount=0
记录上传图片数
foreachformNameinupload.objFile'
列出所有上传了的文件
setfile=upload.file(formName)'
生成一个文件对象
intFileSize=file.FileSize
iffile.FileSize>
0andfile.filesize<
=2621440then'
如果FileSize>
0说明有文件数据
FileNameext=LCase(Right(file.fileName,4))
最文件名的后四位字符,并转成小写
ifFileNameext="
.jpg"
orFileNameext="
.gif"
.GIF"
.JPG"
then
'
判断图片的格式,你也可以去掉不判断
Pic_Name=file.fileName'
将文件名赋值给变量Pic_Name
file.SaveAsServer.mappath(formPath&
file.FileName)
'
保存文件
iCount=iCount+1
else
response.write"
scriptlanguage=javascript>
"
alert('
你上传的图片格式不正确'
);
response.write"
history.go(-1);
response.write"
/script>
response.end
endif
else
iffile.filesize>
2621440then'
如果文件大于256K,这个数值你可以自己算256×
1024
上传的图片大于256K,上传失败!
response.write"
response.write"
response.end
endif
setfile=nothing
next
up_pic=Pic_Name
本函数的作用是,将上传的图片上传到文件夹中,并将文件名返回
endfunction
html>
head>
title>
添加新数据<
/title>
metahttp-equiv="
content-type"
content="
text/html;
charset=gb2312"
linkhref="
style.css"
rel="
stylesheet"
type="
text/css"
/head>
bodybgcolor="
4189dd"
leftmargin="
0"
topmargin="
marginwidth="
marginheight="
p>
&
nbsp;
/p>
tablewidth="
80%"
border="
align="
center"
cellpadding="
cellspacing="
2"
bgcolor="
00209f"
<
tr>
tdbgcolor="
a9c7ec"
100%"
tdheight="
30"
#ffffff"
divalign="
欢迎使用<
imgsrc="
../../image/di02.gif"
width="
95"
height="
26"
absmiddle"
后台管理系统<
/div>
/td>
/tr>
td>
<
%dimbaseclass,childclass,childbm,pbm,picture,pname,publish,factory,dw,size,price,dz,yhj,cd,num,goodsstate
baseclass=mid(request.form("
baseclass"
),24)
baseclass=mid(upload.form("
childclass=mid(trim(request.form("
childclass"
)),5)
childclass=mid(trim(upload.form("
childbm=mid(trim(request.form("
)),1,4)
childbm=mid(trim(upload.form("
picture=request.form("
picture"
picname=up_pic()'
pname=request.form("
pname=upload.form("
factory=request.form("
factory"
factory=upload.form("
dw=request.form("
dw"
dw=upload.form("
size=request.form("
size"
size=upload.form("
price=upload.form("
price"
dz=upload.form("
dz"
num=upload.form("
num"
goodsstate=upload.form("
goodsstate"
publish=session("
username"
setrs=server.createobject("
adodb.recordset"
sql="
selecttop1*fromgoodswherebaseclass='
baseclass&
andchildclass='
childclass&
orderbypbmdesc"
rs.opensql,conn,1,3
ifrs.recordcount=0then
pbm=childbm&
001"
else
pbm=childbm+right(cstr(rs("
pbm"
)+1),3)
endif
rs.addnew
rs("
)=picname
)=baseclass
)=childclass
)=pbm
)=factory
)=dw
)=size
)=price
)=dz
)=num
rs("
)=goodsstate
publish"
)=publish
inputtime"
)=now()
yhj"
)=upload.form("
info"
cd"
rs.update
rs.close'
使用完后关闭记录集setrs=nothing
conn.close'
关闭数据库连接对象setconn=nothing
%>
palign="
fontcolor="
#ff3300"
strong>
数据提交成功!
/strong>
/font>
ahref="
goodsaddform.asp"
/a>
版权所有:
如遇到程序使用问题请及时与程序管理员联系<
/table>
/body>
/html>
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图片 上传 功能模块 与其 网站 融合
![提示](https://static.bdocx.com/images/bang_tan.gif)