471,570 Members | 988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

server.mappath() parent

How to use server.mappath() parent folder correctly:

Server.MapPath("../test.asp")

Thank you for the hint.

May 3 '07 #1
4 6910
MapPath
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash
(\), the MapPath method returns a path as if Path is a full virtual path. If Path doesn't start with a slash, the MapPath method
returns a path relative to the directory of the .asp file being processed.
Remarks
The MapPath method does not support relative path syntax (.) or (..). For example, the following relative path, ../MyDir/MyFile.txt,
returns an error.

The MapPath method does not check whether the path it returns is valid or exists on the server.

Because the MapPath method maps a path regardless of whether the specified directories currently exist, you can use the MapPath
method to map a path to a physical directory structure, and then pass that path to a component that creates the specified directory
or file on the server.



<vu******@gmail.comwrote in message news:11**********************@q75g2000hsh.googlegr oups.com...
How to use server.mappath() parent folder correctly:

Server.MapPath("../test.asp")

Thank you for the hint.

May 3 '07 #2
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
MapPath
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash
(\), the MapPath method returns a path as if Path is a full virtual path. If Path doesn't start with a slash, the MapPath method
returns a path relative to the directory of the .asp file being processed.
Remarks
The MapPath method does not support relative path syntax (.) or (..). For example, the following relative path, ../MyDir/MyFile.txt,
returns an error.

The MapPath method does not check whether the path it returns is valid or exists on the server.

Because the MapPath method maps a path regardless of whether the specified directories currently exist, you can use the MapPath
method to map a path to a physical directory structure, and then pass that path to a component that creates the specified directory
or file on the server.

<vunet...@gmail.comwrote in messagenews:11**********************@q75g2000hsh.g ooglegroups.com...
How to use server.mappath() parent folder correctly:
Server.MapPath("../test.asp")
Thank you for the hint.
so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:

www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp

May 3 '07 #3
vu******@gmail.com wrote on 3 May 2007 12:20:44 -0700:
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com>wrote:
>MapPath
The MapPath method maps the specified relative or virtual path to the
corresponding physical directory on the server.

Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory.
If Path starts with either a forward (/) or backward slash (\), the
MapPath method returns a path as if Path is a full virtual path. If Path
doesn't start with a slash, the MapPath method returns a path relative to
the directory of the .asp file being processed. Remarks The MapPath
method does not support relative path syntax (.) or (..). For example,
the following relative path, ../MyDir/MyFile.txt, returns an error.

The MapPath method does not check whether the path it returns is valid or
exists on the server.

Because the MapPath method maps a path regardless of whether the
specified directories currently exist, you can use the MapPath method to
map a path to a physical directory structure, and then pass that path to
a component that creates the specified directory or file on the server.

<vunet...@gmail.comwrote in messagenews:11**********************@q75g2000hsh.g ooglegroups.com...
>>How to use server.mappath() parent folder correctly:
>>Server.MapPath("../test.asp")
>>Thank you for the hint.

so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:

www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp
Try

sFile = Server.MapPath("/temp/temp/temp.asp")

Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If oFS.FileExists(sFile) Then
'file exists
End If
Set oFS = Nothing

Of course, this isn't a perfect solution - for instance, there may be an
ISAPI pre-processor that handles incoming requests and redirects them
elsewhere based on the path, so the file /temp/temp/temp.asp might not even
reside on the same server, or in the same path structure, as
/filder2/file1.asp. Assuming a "normal" configuration, this should work
though.

Dan
May 4 '07 #4
On May 4, 7:40 am, "Daniel Crichton" <msn...@worldofspack.comwrote:
vunet...@gmail.com wrote on 3 May 2007 12:20:44 -0700:
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com>wrote:
MapPath
The MapPath method maps the specified relative or virtual path to the
corresponding physical directory on the server.
Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory.
If Path starts with either a forward (/) or backward slash (\), the
MapPath method returns a path as if Path is a full virtual path. If Path
doesn't start with a slash, the MapPath method returns a path relative to
the directory of the .asp file being processed. Remarks The MapPath
method does not support relative path syntax (.) or (..). For example,
the following relative path, ../MyDir/MyFile.txt, returns an error.
The MapPath method does not check whether the path it returns is valid or
exists on the server.
Because the MapPath method maps a path regardless of whether the
specified directories currently exist, you can use the MapPath method to
map a path to a physical directory structure, and then pass that path to
a component that creates the specified directory or file on the server.
<vunet...@gmail.comwrote in messagenews:11**********************@q75g2000hsh.g ooglegroups.com...
How to use server.mappath() parent folder correctly:
>Server.MapPath("../test.asp")
>Thank you for the hint.
so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:
www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp

Try

sFile = Server.MapPath("/temp/temp/temp.asp")

Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If oFS.FileExists(sFile) Then
'file exists
End If
Set oFS = Nothing

Of course, this isn't a perfect solution - for instance, there may be an
ISAPI pre-processor that handles incoming requests and redirects them
elsewhere based on the path, so the file /temp/temp/temp.asp might not even
reside on the same server, or in the same path structure, as
/filder2/file1.asp. Assuming a "normal" configuration, this should work
though.

Dan
let me try. thanks a lot

May 4 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by John Rebbeck | last post: by
4 posts views Thread by Mark Horrocks | last post: by
6 posts views Thread by darrel | last post: by
4 posts views Thread by jamting | last post: by
3 posts views Thread by rn5a | last post: by
3 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.