最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
文件上传代码
时间:2022-07-02 23:14:52 编辑:袖梨 来源:一聚教程网
文件上传代码,这段上传代码都不知道是我什么时候写的了,哈哈还是也拿出来吧,
<%
dim filename,filepath,filetype,obstream,fso,fod,sql'定义变量
filepath=request.Form("filename"'取得文件路径
if len(filepath)=0 or instr(filepath,"'"<>0 then'路径的合法性
response.Redirect("firstfile.asp?info=文件不合法"
else
filename=mid(filepath,instrrev(filepath,""+1)'取得文件名
filetype=mid(filename,instrrev(filename,"."+1)'取得文件类型
imagepath=server.mappath("image"
if instr(filetype,"jpg"<>0 or instr(filetype,"gif"<>0 or instr(filetype,"png"<>0 then'判断是否为我们要上传的文件
set fso=server.createobject("scripting.filesystemobject"
set fod=fso.getfolder(imagepath)
for each f in fod.files
f=mid(f,instrrev(f,""+1)
if f=filename then'判断文件是否存在
response.Redirect("firstfile.asp?info=文件己存在"
end if
next
set fso=nothing
set obstream=server.createobject("adodb.stream"
obstream.type=1
obstream.open
obstream.loadfromfile filepath
path="image"&filename
if obstream.size<500*1024 then
sql="select * from jimmy"
call opendb()
rs.open sql,cnn,1,3
rs.addnew
rs("image_path"=path
rs.update
call closedb()
obstream.savetofile server.mappath(path)'上传文件
response.Redirect("firstfile.asp?info=上传文件成功"
end if
obstream.close
set obstream=nothing
else
response.Redirect("firstfile.asp?info=文件不合法,必须是图片文件jpg,gif,png,"
end if
end if
%>
相关文章
- 王者荣耀新宫本武藏连招操作 2022新版宫本怎么玩攻略[多图] 05-08
- 代号鸢左慈紫藤醉日怎么样 05-08
- 塞尔达传说王国之泪大的佐纳乌能源获得方法攻略 05-08
- paypal官网安卓版2024 05-08
- 代号鸢左慈紫藤醉日怎么样 代号鸢5.9新地宫介绍 05-08
- 虎符交易所最新安卓版2024 05-08