Passing string to Server.MapPath

Discussion in 'ASP General' started by Jake, Feb 8, 2005.

  1. Jake

    Jake Guest

    How can I pass the results of a form field submitted to this statement
    below?

    <%
    Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
    '### This Works
    '###Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath("body.txt"))
    '### This Doesnt work
    Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(" &
    request.form("MyFileName") & "))

    WHILE NOT MyTextFile.AtEndOfStream
    Response.Write(MyTextFile.ReadLine & Chr(10))
    WEND
    MyTextFile.Close
    %>


    Thanks in advance!
     
    Jake, Feb 8, 2005
    #1
    1. Advertising

  2. Jake

    Steven Burn Guest

    strTemp = Request.Form("MyFileName")

    Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(strTemp))

    Or

    Set MyTextFile =
    MyFileObj.OpenTextFile(Server.MapPath(Request.Form("MyFileName")))

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    "Jake" <> wrote in message
    news:#...
    > How can I pass the results of a form field submitted to this statement
    > below?
    >
    > <%
    > Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
    > '### This Works
    > '###Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath("body.txt"))
    > '### This Doesnt work
    > Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(" &
    > request.form("MyFileName") & "))
    >
    > WHILE NOT MyTextFile.AtEndOfStream
    > Response.Write(MyTextFile.ReadLine & Chr(10))
    > WEND
    > MyTextFile.Close
    > %>
    >
    >
    > Thanks in advance!
    >
    >
     
    Steven Burn, Feb 8, 2005
    #2
    1. Advertising

  3. Jake

    Jake Guest

    Thanks a bunch!!!


    "Steven Burn" <> wrote in message
    news:%...
    > strTemp = Request.Form("MyFileName")
    >
    > Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(strTemp))
    >
    > Or
    >
    > Set MyTextFile =
    > MyFileObj.OpenTextFile(Server.MapPath(Request.Form("MyFileName")))
    >
    > --
    > Regards
    >
    > Steven Burn
    > Ur I.T. Mate Group
    > www.it-mate.co.uk
    >
    > Keeping it FREE!
    >
    > "Jake" <> wrote in message
    > news:#...
    >> How can I pass the results of a form field submitted to this statement
    >> below?
    >>
    >> <%
    >> Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
    >> '### This Works
    >> '###Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath("body.txt"))
    >> '### This Doesnt work
    >> Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(" &
    >> request.form("MyFileName") & "))
    >>
    >> WHILE NOT MyTextFile.AtEndOfStream
    >> Response.Write(MyTextFile.ReadLine & Chr(10))
    >> WEND
    >> MyTextFile.Close
    >> %>
    >>
    >>
    >> Thanks in advance!
    >>
    >>

    >
    >
     
    Jake, Feb 9, 2005
    #3
  4. Jake

    Steven Burn Guest

    Your welcome.....

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    "Jake" <> wrote in message
    news:...
    > Thanks a bunch!!!
    >
    >
    > "Steven Burn" <> wrote in message
    > news:%...
    > > strTemp = Request.Form("MyFileName")
    > >
    > > Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(strTemp))
    > >
    > > Or
    > >
    > > Set MyTextFile =
    > > MyFileObj.OpenTextFile(Server.MapPath(Request.Form("MyFileName")))
    > >
    > > --
    > > Regards
    > >
    > > Steven Burn
    > > Ur I.T. Mate Group
    > > www.it-mate.co.uk
    > >
    > > Keeping it FREE!
    > >
    > > "Jake" <> wrote in message
    > > news:#...
    > >> How can I pass the results of a form field submitted to this statement
    > >> below?
    > >>
    > >> <%
    > >> Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
    > >> '### This Works
    > >> '###Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath("body.txt"))
    > >> '### This Doesnt work
    > >> Set MyTextFile = MyFileObj.OpenTextFile(Server.MapPath(" &
    > >> request.form("MyFileName") & "))
    > >>
    > >> WHILE NOT MyTextFile.AtEndOfStream
    > >> Response.Write(MyTextFile.ReadLine & Chr(10))
    > >> WEND
    > >> MyTextFile.Close
    > >> %>
    > >>
    > >>
    > >> Thanks in advance!
    > >>
    > >>

    > >
    > >

    >
    >
     
    Steven Burn, Feb 9, 2005
    #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,179
    Scott M.
    Jan 17, 2010
  2. Curt_C [MVP]
    Replies:
    0
    Views:
    1,915
    Curt_C [MVP]
    Jan 22, 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,156
    Juan T. Llibre
    Mar 11, 2007
  4. Replies:
    4
    Views:
    971
    Juan T. Llibre
    Oct 7, 2007
  5. Dave
    Replies:
    7
    Views:
    153
Loading...

Share This Page