server.mappath() parent

server.mappath() parent

am 03.05.2007 16:47:53 von vunet.us

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

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

Thank you for the hint.

Re: server.mappath() parent

am 03.05.2007 19:35:15 von Jon Paal

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.







wrote in message news:1178203673.452619.296280@q75g2000hsh.googlegroups.com.. .
> How to use server.mappath() parent folder correctly:
>
> Server.MapPath("../test.asp")
>
> Thank you for the hint.
>

Re: server.mappath() parent

am 03.05.2007 21:20:44 von vunet.us

On May 3, 1:35 pm, "Jon Paal [MSMD]" 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.
>
> wrote in messagenews:1178203673.452619.296280@q75g2000hsh.googlegroup s.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

Re: server.mappath() parent

am 04.05.2007 13:40:31 von Daniel Crichton

vunet.us@gmail.com wrote on 3 May 2007 12:20:44 -0700:

> On May 3, 1:35 pm, "Jon Paal [MSMD]" 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.
>>
>> wrote in messagenews:1178203673.452619.296280@q75g2000hsh.googlegroup s.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

Re: server.mappath() parent

am 04.05.2007 16:05:49 von vunet.us

On May 4, 7:40 am, "Daniel Crichton" wrote:
> vunet...@gmail.com wrote on 3 May 2007 12:20:44 -0700:
>
>
>
> > On May 3, 1:35 pm, "Jon Paal [MSMD]" > 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.
>
> >> wrote in messagenews:1178203673.452619.296280@q75g2000hsh.googlegroup s.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