Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Penang, Malaysia
    Posts
    212

    Unanswered: Server MapPath Issue

    I wrote this in my asp page:

    response.Write Server.MapPath(Request.ServerVariables("PATH_INFO" ))

    I got this:
    c:\inetpub\wwwroot\testupload\test1.asp


    I want only until:
    c:\inetpub\wwwroot\testupload\

    I tried this:
    response.Write Server.MapPath("/")

    but got this instead:
    c:\inetpub\wwwroot

    So can anybody help?
    Patrick Chua
    LBMS ( Learn By My Self) NPQ ( No paper Qualification )

  2. #2
    Join Date
    Jul 2003
    Location
    Penang, Malaysia
    Posts
    212
    Okay...I'll answer my own question...
    Code:
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    p=fs.GetParentFolderName(Server.MapPath(Request.ServerVariables("PATH_INFO")))
    
    Response.Write("The parent folder name is: " & p)
    
    set fs=nothing
    Patrick Chua
    LBMS ( Learn By My Self) NPQ ( No paper Qualification )

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    And here are some other somewhat similar cool things you can do:

    <%
    '!!!
    Response.Write "Server.MapPath with . : " & Server.MapPath(".") & "<br>"
    Response.Write "Server.MapPath with .. : " & Server.MapPath("..") & "<br>"
    Response.Write "Server.MapPath with ../logs : " & Server.MapPath("../logs") & "<br>"
    Response.Write "Server.MapPath with / : " & Server.MapPath("/") & "<br>"
    Response.Write "Server.MapPath with /. : " & Server.MapPath("/.") & "<br>"
    Response.Write "Server.MapPath with /.. : " & Server.MapPath("/..") & "<br>"
    Response.Write "Server.MapPath with /../ : " & Server.MapPath("/../") & "<br>"
    Response.Write "Server.MapPath with /../.. : " & Server.MapPath("/../..") & "<br>"
    Response.Write "Server.MapPath with /../../ : " & Server.MapPath("/../../") & "<br>"
    Response.Write "Server.MapPath with /../www : " & Server.MapPath("/../www") & "<br>"
    Response.Write "Server.MapPath with /../logs : " & Server.MapPath("/../logs") & "<br>"
    Response.Write "Server.MapPath with /../hi : " & Server.MapPath("/../hi") & "<br>"

    %>
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •