server.mappath() parent

Discussion in 'ASP General' started by vunet.us@gmail.com, May 3, 2007.

  1. Guest

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

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

    Thank you for the hint.
    , May 3, 2007
    #1
    1. Advertising

  2. Guest

    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.
    >
    > <> wrote in messagenews:...
    > > 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, 2007
    #2
    1. Advertising

  3. 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.
    >>
    >> <> wrote in messagenews:...
    >>> 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
    Daniel Crichton, May 4, 2007
    #3
  4. Guest

    On May 4, 7:40 am, "Daniel Crichton" <> wrote:
    > 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.

    >
    > >> <> wrote in messagenews:...
    > >>> 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, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    5
    Views:
    11,161
    Scott M.
    Jan 17, 2010
  2. Peter Row
    Replies:
    0
    Views:
    466
    Peter Row
    Mar 1, 2004
  3. =?Utf-8?B?dHBhcmtzNjk=?=

    server.mappath vs. request.mappath

    =?Utf-8?B?dHBhcmtzNjk=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,148
    Juan T. Llibre
    Mar 11, 2007
  4. Replies:
    4
    Views:
    968
    Juan T. Llibre
    Oct 7, 2007
  5. Lovely Angel
    Replies:
    23
    Views:
    796
    Roland Hall
    Aug 29, 2004
Loading...

Share This Page