我使用的无组件上传,如何在上传的同时过滤一些文件当中的非法字符或内容呢?

oeye 2004-12-23 10:16:38
现在限制文件的类型、文件的大小功能都有了,我还要一个过滤功能,我知道使用asp的opentextfile函数,可具体我不知道该怎样写,希望能得到大家相助,以下是部分源码,麻烦你们告诉我写什么代码,加在什么位置比较好,谢谢!

-----------------------源码开始--------------------
dim upload,file,formName,formPath,iCount
set upload=new upload_5xsoft ''建立上传对象
if upload.form("filepath")="" then ''得到上传目录
Response.write "<script language='javascript'>alert('系统提示:\n\n请输入要上传至的目录!');location.href='javascript:history.back()'</script>"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if
iCount=0
for each formName in upload.objFile ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if Instr(filetype,GetExtendName(file.filename)) then
else
Response.write "<script language='javascript'>alert('系统提示:\n\n不允许上传"&GetExtendName(file.filename)&"类型文件!');location.href='javascript:history.back()'</script>"
set upload=nothing
response.end
end if
if file.filesize>maxsize*1024 then
Response.write "<script language='javascript'>alert('系统提示:\n\n文件大小不能超过"&maxsize&"K,请返回重试!');location.href='javascript:history.back()'</script>"
set upload=nothing
response.end
end if
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing '删除此对象
function GetExtendName(filename)
dim ExtName
ExtName = LCase(FileName)
ExtName = right(ExtName,4)
ExtName = right(ExtName,4-Instr(ExtName,"."))
GetExtendName = ExtName
end function
%>
<script language="javascript">
if (confirm("<%=icount%>个文件上传成功,是否继续上传?"))
window.location.href="javascript:history.back()"
</script>
---------------------------------------------源码结束---------------------------------
...全文
85 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oeye 2004-12-23
  • 打赏
  • 举报
回复
up again
oeye 2004-12-23
  • 打赏
  • 举报
回复
up
oeye 2004-12-23
  • 打赏
  • 举报
回复
这里太旺了,没办法UP一下:(

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧