最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
无组件上传文件,一个函数搞定
时间:2022-06-30 10:26:18 编辑:袖梨 来源:一聚教程网
本函数是用“化境ASP无组件上传程序2.0”上传文件。
核心函数:
<%
'''''==============================
'函数名:upfile
'作用: 使用“化境上传组件”上传文件到服务器上
'参数: file1 文件对象
' savepath 文件要保存的相对路径,如"../"上一级上录,""同目录
' maxsize 允许上传文件的最大值,单位KB.为0不限大小.
' savetype 允许上传文件的类型,0不限制,限制的格式.如.jpg|.bmp|.zip
'返回值:返回上传信息,也可自己根据须要设定返回值
'前提:set upload=new upload_5xsoft ''建立上传对象
' set file1=upload.file("file1") ''生成一个文件对象
'Designer:suercool
function upfile(file1,savepath,maxsize,savetype)
if file1.filename="" and file1.filesize<=0 then
upfile=""
exit function
end if
if maxsize<>"0" and file1.filesize>clng(maxsize)*1024 then
upfile=""
exit function
end if
dim filename,filetype
filename=file1.filename
filetype=getfiletype(filename)
if savetype<>"0" then
dim arrtype,i,foundtype
arrtype=split(savetype,"|")
foundtype=false
for i = 0 to ubound(arrtype)
if lcase(arrtype(i))=filetype then
foundtype=true
exit for
end if
next
if not foundtype then
upfile=""
exit function
end if end if
randomize()
filepath=savepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&int(rnd*9999)&filetype
核心函数:
<%
'''''==============================
'函数名:upfile
'作用: 使用“化境上传组件”上传文件到服务器上
'参数: file1 文件对象
' savepath 文件要保存的相对路径,如"../"上一级上录,""同目录
' maxsize 允许上传文件的最大值,单位KB.为0不限大小.
' savetype 允许上传文件的类型,0不限制,限制的格式.如.jpg|.bmp|.zip
'返回值:返回上传信息,也可自己根据须要设定返回值
'前提:set upload=new upload_5xsoft ''建立上传对象
' set file1=upload.file("file1") ''生成一个文件对象
'Designer:suercool
function upfile(file1,savepath,maxsize,savetype)
if file1.filename="" and file1.filesize<=0 then
upfile=""
exit function
end if
if maxsize<>"0" and file1.filesize>clng(maxsize)*1024 then
upfile=""
exit function
end if
dim filename,filetype
filename=file1.filename
filetype=getfiletype(filename)
if savetype<>"0" then
dim arrtype,i,foundtype
arrtype=split(savetype,"|")
foundtype=false
for i = 0 to ubound(arrtype)
if lcase(arrtype(i))=filetype then
foundtype=true
exit for
end if
next
if not foundtype then
upfile=""
exit function
end if end if
randomize()
filepath=savepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&int(rnd*9999)&filetype
相关文章
- 陌陌网页版登录入口-官方陌陌网页版登录官网 12-20
- 夸克网页版入口-一键直达夸克浏览器网页版 12-20
- 奇漫屋漫画入口-奇漫屋免费漫画在线观看入口 12-20
- 蛙漫wanna官网入口-蛙漫wanna最新官网链接直达 12-20
- 学信网官网入口在哪-学信网学籍查询快速通道 12-20
- 俄罗斯引擎官网-精准地图导航与实时新闻资讯聚合 12-20