最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
文件上传代码
时间:2008-06-28 编辑:简简单单 来源:一聚教程网
文件上传代码,这段上传代码都不知道是我什么时候写的了,哈哈还是也拿出来吧,
<%
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
%>
-
上一个: asp分页代码(通用)
-
下一个: asp参数传递到下一页面
相关文章
- Laravel 5.2文件上传的功能使用示例 08-27
- WebUploader文件上传组件示例 08-24
- Plupload上传组件 + java实现文件上传例子 05-13
- Swift HTTP网络操作库Alamofire实现文件上传详解 12-09
- SWFObject文件上传插件的使用教程 10-09
- java中struts2实现文件上传下载功能 05-30