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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server.Mappath

Status
Not open for further replies.

jeepxo

Programmer
Oct 1, 2002
228
CA
I get how server.mappath works.
server.mappath(.) gets my current folder
server.mappath(\) gets me to the root of the web etc.

Here's my problem, I can't be assured that the application itself is at the root of the web.

All of the web pages are in the inetpub directory.
All of the supporting pages are in a virtual directory called documents.

If I'm at the root then server.mappath(documents) returns the physical path of the virtual directory, not a problem.

If I am in a sub folder though, how do I get to the parent folder, then into the virtual folder?

For example, my asp page is
<%website%>\1_folder_down\2_folders_down\test.asp
my virtual directory though would appear as
<%website%>\1_folder_down\documents

Parent Paths are enabled. I'm looking for a way to move up one folder, then into the virtual directory rather than move up to the root then into the virtual directory





To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
I must be missing something about your explanation.

Code:
server.mappath('file or folder')

Returns the physical path for the file or folder name specified withing the site structure

but if tou are trying to get to the physical path of the running script, using
Code:
request.servervariables["PATH_TRANSLATED")
or
Code:
request.servervariables("APPL_PHYSICAL_PATH")
would probably be better.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I'm not trying to get to either of those.

Here's the scenario.

I have

website
website\folder1
website\folder2
website\virtual_directory

website could be a web itself (eg myapplication.companyweb.com). Bob's your uncle, not a problem to get to the virtual directory from anywhere. I simply go to the root then into the virtual directory with
Code:
server.mappath(\virtural_directory)

The problem is myapplication may not be a website itself. It may be a physical folder under the companywebsite folder, that the company set as an application in IIS. It would have it's own application pool and operate as if it were a website.

That would give me a web address of .
It has it's own application pool, and for all intents and purposes it acts like it's own website (with it's own application variables and it's own global.asa) but it is not a root web.





To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
as they are all in the same physical location is it simply not a matter of getting the root path then appending the name of the "virtual_folder"?


Code:
DocumentPath = server.getmappath("/") & "\documents\"

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
They are not in the same physical location.

All web pages are in Inetpub\somewhere.

All supporting documentation is in Program Files\myCompany\myApplication

I can't just map to c:\program files... because that folder may not reside on the system drive

To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
I was looking at it the wrong way.

I know how deep I am in my own folder structure, but I couldn't be assured that my application was a root application. Instead of worrying where my root is, I just need to get back to my application root.

I start with getting my own address relative to the website
Code:
myAddr = Request.ServerVariables("URL")
Then I find out how many folders down I am relative to the website
Code:
findRoot = split(myAddr,"/")
I know that my virtual document directory is 1 folder below my root so I start with
Code:
myDocumentPath = "\"
I know that the server variable gives me a "/" before each folder
so if I have more than 2 "/"'s my application is not in it's own website, it's an application inside another website. (companysite.com\myapplication rather than myapplication.companywebsite.com)

Code:
    if ubound(findRoot) > 2 then
        myDocumentPath = myDocumentPath & findRoot(ubound(findRoot)-2) & "\"
    end if
    
    myDocumentPath = myDocumentPath & "Documents\"

then

Code:
myPhysicalPath = server.mappath(myDocumentPath)
will give me the physical path for the virtual directory.


To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
So is this path "Program Files\myCompany\myApplication" on the client machine?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
It's a web app so if you mean "client machine" as in the person coming to it through their browser, no.
If you mean client machine as in the company who bought the app, yes.
It could be on a drive physically on the webserver, or it could be on a network drive.


To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
Giving a web application permission to read files outside of the server is not a good move and no decent server admin would allow such a breach of security.

Why doesn't your application installer place the documents within the webserver structure?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top