server.mappath() parent
am 03.05.2007 16:47:53 von vunet.usHow to use server.mappath() parent folder correctly:
Server.MapPath("../test.asp")
Thank you for the hint.
How to use server.mappath() parent folder correctly:
Server.MapPath("../test.asp")
Thank you for the hint.
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.
> How to use server.mappath() parent folder correctly:
>
> Server.MapPath("../test.asp")
>
> Thank you for the hint.
>
On May 3, 1:35 pm, "Jon Paal [MSMD]"
> 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.
>
>
> > 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
vunet.us@gmail.com wrote on 3 May 2007 12:20:44 -0700:
> On May 3, 1:35 pm, "Jon Paal [MSMD]"
>> 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.
>>
>>
>>> 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
On May 4, 7:40 am, "Daniel Crichton"
> vunet...@gmail.com wrote on 3 May 2007 12:20:44 -0700:
>
>
>
> > On May 3, 1:35 pm, "Jon Paal [MSMD]"
> >> 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.
>
> >>
> >>> 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