SEO笔记

asp获取文件后缀名两种方法

2025年11月18日 11:03 # asp # Htm

前端需要显示文件后缀时,我们通常在链接中需要给出title信息,这样方便seo优化。

方法一:使用 ASP FileSystemObject 对象

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

Response.Write("文件的文件扩展名是:")
Response.Write(fs.GetExtensionName("d:\file\abc.jpg"))

set fs=nothing
%>

方法二:使用 mid 与instrrev 函数

<%
filename="d:\file\abc.jpg"
kzm=Mid(filename,InStrRev(filename,".")+1)'使用时把中文括号改变为英文括号
Response.Write("文件的文件扩展名是:"&kzm)
%>