次のような URL があるとします: http://website.com/folder/myfile.asp
「myfile.asp」のみを書き出すスクリプトを作成するにはどうすればよいですか
次のような URL があるとします: http://website.com/folder/myfile.asp
「myfile.asp」のみを書き出すスクリプトを作成するにはどうすればよいですか
Here is the code needed.
<%
Dim arrPath: arrPath = Split(Request.ServerVariables("SCRIPT_NAME"), "/")
Dim fileName: fileName = arrPath(UBound(arrPath))
%>
Gets an array of elements in the current scripts URL path and then selects the last element in that array which will be the filename.
Now if you expect to be doing any significant work in a ASP/VBScript I would recommend you spend some time reading all the content related to VBScript here. There isnt an overwhelming amount of info there but the time spent will pay itself back quite quickly.
これを使って:
<% = Request.ServerVariables("SCRIPT_NAME") %>
ここにあなたのための簡単な機能があります
<%
Function getFileName(lsPath)
' Obtain the virtual file path '
lsPath = Request.ServerVariables("SCRIPT_NAME")
' Split the path along the /s. This creates a one-dimensional array '
arPath = Split(lsPath, "/")
' The last item in the array contains the file name '
GetFileName =arPath(UBound(arPath,1))
End Function
%>
<%=getFileName(Request.ServerVariables("SCRIPT_NAME"))%>