2

次のような URL があるとします: http://website.com/folder/myfile.asp

「myfile.asp」のみを書き出すスクリプトを作成するにはどうすればよいですか

4

3 に答える 3

6

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.

于 2012-05-03T08:29:13.090 に答える
0

これを使って:

<% = Request.ServerVariables("SCRIPT_NAME") %>
于 2012-05-02T15:38:18.610 に答える
0

ここにあなたのための簡単な機能があります

<%

 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"))%>
于 2012-05-03T09:42:28.997 に答える