how to get the absolute path from within an asp page?

L

laredotornado

Hello,

Fairly new to ASP, but if I'm programming in the file

<web root>\myapp\mypage.asp

How would I print out "\myapp\" without hard-coding the value of
"\myapp\"?

Thanks, - Dave
 
E

Evertjan.

wrote on 27 aug 2006 in microsoft.public.inetserver.asp.general:
Hello,

Fairly new to ASP, but if I'm programming in the file

<web root>\myapp\mypage.asp

How would I print out "\myapp\" without hard-coding the value of
"\myapp\"?

In asp and html, urls are written with a /, no a \

<%=Request.ServerVariables("PATH_INFO")%>

will write: /myapp/mypage.asp


<%
pathInfo = Request.ServerVariables("PATH_INFO")
lastSlashPos = InStrRev(pathInfo , "/")
response.write left(pathInfo,lastSlashPos)
%>

This should write: /myapp/
 
F

Farshad Hemmati

You can use this code:

pathInfo = Request.ServerVariables("SCRIPT_NAME")
MYPATH = left(pathInfo,InStrRev(pathInfo , "/"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top