Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get file name in vbscript/asp

Status
Not open for further replies.

avivit

Technical User
Joined
Jul 5, 2000
Messages
456
Location
IL
Hi
I'd like to get the current document name (asp file) in vbscript/asp and send that name to the following called function which is in another included file.

All I need to know is the getFile command that will tell me the file name (the "nameOfFile" argument in the function)

sub lastModified(nameOfFile)
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile(Server.MapPath(nameOfFile))
Response.Write(&quot;<!-- Last modified in: &quot; & f.DateLastModified & &quot; -->&quot;)
set f=nothing
set fs=nothing
end sub

Thanks much
 
No. What I need is the current url.
In javascript it's based on: &quot;document.URL&quot; command
What is it in vbscript, so it'll work in my asp too?
 
the following is in test.asp:

<%
dim url, vpath

vpath = split(Request.ServerVariables(&quot;SCRIPT_NAME&quot;), &quot;/&quot;)
url = vpath(ubound(vpath))

response.write (url)
%>

test.asp is displayed

are we talking about the same thing?

 
Yes thanks very very much.
It was me that didn't understand that u understood right away what I needed. I didn;t understand what is the &quot;Script)Name&quot;).

It is perfectly doing the job. Great.

I wonder, I saw that u can also use

vpath = split(Request.ServerVariables(&quot;URL&quot;), &quot;/&quot;)
INSTEAD OF &quot;Script_Name&quot;, and it gives the same results.
Any ideas what ARE the differences?

Btw - I also got the following idea, which works as well, but I admit yours is easier:

Dim nameOfFile
nameOfFile = Request.ServerVariables(&quot;URL&quot;)
nameOfFile=Right(nameOfFile, Len(nameOfFile)-InStrRev(nameOfFile, &quot;/&quot;))

Thanks again
 
&quot;It was me that didn't understand that u understood right away what I needed. I didn;t understand what is the &quot;Script)Name&quot;).&quot; -- I thought that might be the case, that's why I rephrased my response. I'm glad it helped you.

As for the diff between SCRIPT_NAME and URL, here is the definitions given at DEVGURU, but I don't see any diff either.... Also, PATH_INFO is the same.... So you have your choice, I guess whichever is easier to type. X-)

SCRIPT_NAME is a virtual path to the script being executed.

URL is the base portion of the URL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top