This page explains how to get the physical path to various subsystem directories. This is useful for components such as ASPupload that need the full directory path.
Your ASP files are located in the "www" subsystem - The vbscript examples on this page show how to access files that are located in another subsystem.
It is important not to hardcode physical directory paths in your code, because they may change over time, and may be different on different servers.
The first step is to retrieve the base directory under which all your subsystems are located.
Use the following ASP code to store the base directory in a variable.
AccountID = "youraccountid" 'Put your own accountID in here.
WWWRoot = Server.mappath("/")
PathArray = split(WWWRoot,"\")
for i = 0 to ubound(PathArray)-2
Base = Base & PathArray(i) & "\"
next
All we're doing here, is backtracking along the physical path to the point below your html folder at 'www\<accountid>'
When you upload to your 'www' folder your files are placed in a physical folder such as:
c:\webpub\www\accountid
When you upload to your database folder - 'mdb', your files are placed in a physical folder such as:
c:\webpub\mdb\accountid
The above code places the string c:\webpub\ into the variable 'Base'.
Now you can simply append the subsystem name and your accountID to this path.
e.g 1 the MDB subsystem - which has security settings appropriate for reading & writing to a MSAccess database.
This ASP code :
Write_subsystem_path = Base & "mdb\" & AccountID
returns the physical path of your mdb directory, which on this server and the account this site is running on, happens to be:
E:\webpub\mdb\accountid
e.g 2 the WRITE subsystem - which is where you would store files that allow the anonymous user write permission only.
You might use this directory to write user feedback that you definitely don't want other surfers looking at. You *could* write this info to a directory that has read permission too.. because if surfers don't know the url, it's unlikely they will guess the path to the file.. it's just an added bit of security to write it to a write only directory. (It is of course readable by a logged on user.)
This ASP code :
Write_subsystem_path = Base & "write\" & AccountID
returns the physical path of your write directory, which on this server and the account this site is running on, happens to be:
E:\webpub\write\accountid
Security Note: While it might seem that it would be easy for some other site owner here to write code that accesses your directories, this is prevented by the fact that each site runs under a different security context, so permission would be denied.
It's also against the rules and grounds for account termination of course! (unless you have permission from the site owner to attempt such access).
If you do have an agreement with another site owner, and require the ability for your code to access files in another domain, contact support@webpub.net to arrange it.
|