asp writes csv WITHOUT complete file path?

Discussion in 'ASP General' started by Scott Gordo, Mar 14, 2006.

  1. Scott Gordo

    Scott Gordo Guest

    I have a simple asp form which writes to a csv.
    The code it's based on (from "ASP for Dummies") is:

    Set peoplefile - _
    filesys.OpenTextFile( _
    "c:\inetpub\wwwroot\gb\gbpeople.txt",1)

    The form is going live soon, and I'd like just a dash of due diligence
    in terms of security. I tried using a relative link to the gbpeople.txt
    file which didn't work. Is there a better way around this without
    reinventing?

    Much thanks,

    Scott
    Scott Gordo, Mar 14, 2006
    #1
    1. Advertising

  2. Scott Gordo

    Patrice Guest

    Server.MapPath ? Where do you want to write this file ? What is the security
    risk you are trying to avoid ?

    --
    Patrice

    "Scott Gordo" <> a écrit dans le message de
    news:...
    > I have a simple asp form which writes to a csv.
    > The code it's based on (from "ASP for Dummies") is:
    >
    > Set peoplefile - _
    > filesys.OpenTextFile( _
    > "c:\inetpub\wwwroot\gb\gbpeople.txt",1)
    >
    > The form is going live soon, and I'd like just a dash of due diligence
    > in terms of security. I tried using a relative link to the gbpeople.txt
    > file which didn't work. Is there a better way around this without
    > reinventing?
    >
    > Much thanks,
    >
    > Scott
    >
    Patrice, Mar 14, 2006
    #2
    1. Advertising

  3. Scott Gordo

    Slim Guest

    have you considered server.mappath()
    http://msdn.microsoft.com/library/d...html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp


    "Scott Gordo" <> wrote in message
    news:...
    >I have a simple asp form which writes to a csv.
    > The code it's based on (from "ASP for Dummies") is:
    >
    > Set peoplefile - _
    > filesys.OpenTextFile( _
    > "c:\inetpub\wwwroot\gb\gbpeople.txt",1)
    >
    > The form is going live soon, and I'd like just a dash of due diligence
    > in terms of security. I tried using a relative link to the gbpeople.txt
    > file which didn't work. Is there a better way around this without
    > reinventing?
    >
    > Much thanks,
    >
    > Scott
    >
    Slim, Mar 14, 2006
    #3
  4. Scott Gordo

    Scott Gordo Guest

    Slim wrote:
    > have you considered server.mappath()
    > http://msdn.microsoft.com/library/d...html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
    >
    >
    > "Scott Gordo" <> wrote in message
    > news:...
    > >I have a simple asp form which writes to a csv.
    > > The code it's based on (from "ASP for Dummies") is:
    > >
    > > Set peoplefile - _
    > > filesys.OpenTextFile( _
    > > "c:\inetpub\wwwroot\gb\gbpeople.txt",1)
    > >
    > > The form is going live soon, and I'd like just a dash of due diligence
    > > in terms of security. I tried using a relative link to the gbpeople.txt
    > > file which didn't work. Is there a better way around this without
    > > reinventing?
    > >
    > > Much thanks,
    > >
    > > Scott
    > >


    I should have mentioned that I'm a hack cluebie....
    It looks like exactly what I'm looking for, but I'm not sure how to
    combine the two.

    My code looks like:
    <%...
    Dim filesys, mgrfile
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set mgrfile = _
    filesys.OpenTextFile(_
    "C:\Inetpub\yadayada\contestants.csv",_
    8, true)
    ....%>

    Microsoft's:
    <%=
    Server.MapPath(Request.ServerVariables("PATH_INFO"))%>

    I figure it's something like
    Set mgrfile =
    Server.MapPath(Request.ServerVariables("contestants.csv", 8, true))?

    Can I get an amen?

    Thanks again.

    Scott
    Scott Gordo, Mar 14, 2006
    #4
  5. Scott Gordo

    Patrice Guest

    Server.MapPath maps a virtual path (such as
    "/myfolder/subfolder/myfile.txt") to a physical path
    ("c:\mysites\thisapp\myfolder\subfolder\myfile.txt").

    ServerVariables allows to retrieve some server defined variables (such as
    the path to the current path). The Microsoft sample does likely something
    like displaying the physical path of the current page.

    In your case try Request.ServerMapPath("/whereyouwanttostore/yourfile.txt")

    --
    Patrice

    "Scott Gordo" <> a écrit dans le message de
    news:...
    >
    > Slim wrote:
    > > have you considered server.mappath()
    > >

    http://msdn.microsoft.com/library/d...html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
    > >
    > >
    > > "Scott Gordo" <> wrote in message
    > > news:...
    > > >I have a simple asp form which writes to a csv.
    > > > The code it's based on (from "ASP for Dummies") is:
    > > >
    > > > Set peoplefile - _
    > > > filesys.OpenTextFile( _
    > > > "c:\inetpub\wwwroot\gb\gbpeople.txt",1)
    > > >
    > > > The form is going live soon, and I'd like just a dash of due diligence
    > > > in terms of security. I tried using a relative link to the

    gbpeople.txt
    > > > file which didn't work. Is there a better way around this without
    > > > reinventing?
    > > >
    > > > Much thanks,
    > > >
    > > > Scott
    > > >

    >
    > I should have mentioned that I'm a hack cluebie....
    > It looks like exactly what I'm looking for, but I'm not sure how to
    > combine the two.
    >
    > My code looks like:
    > <%...
    > Dim filesys, mgrfile
    > Set filesys = CreateObject("Scripting.FileSystemObject")
    > Set mgrfile = _
    > filesys.OpenTextFile(_
    > "C:\Inetpub\yadayada\contestants.csv",_
    > 8, true)
    > ...%>
    >
    > Microsoft's:
    > <%=
    > Server.MapPath(Request.ServerVariables("PATH_INFO"))%>
    >
    > I figure it's something like
    > Set mgrfile =
    > Server.MapPath(Request.ServerVariables("contestants.csv", 8, true))?
    >
    > Can I get an amen?
    >
    > Thanks again.
    >
    > Scott
    >
    Patrice, Mar 14, 2006
    #5
  6. Scott Gordo

    Scott Gordo Guest

    Patrice wrote:
    > Server.MapPath maps a virtual path (such as
    > "/myfolder/subfolder/myfile.txt") to a physical path
    > ("c:\mysites\thisapp\myfolder\subfolder\myfile.txt").
    >
    > ServerVariables allows to retrieve some server defined variables (such as
    > the path to the current path). The Microsoft sample does likely something
    > like displaying the physical path of the current page.
    >
    > In your case try Request.ServerMapPath("/whereyouwanttostore/yourfile.txt")
    >
    > --
    > Patrice
    >
    > "Scott Gordo" <> a écrit dans le message de
    > news:...
    > >
    > > Slim wrote:
    > > > have you considered server.mappath()
    > > >

    > http://msdn.microsoft.com/library/d...html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
    > > >
    > > >
    > > > "Scott Gordo" <> wrote in message
    > > > news:...
    > > > >I have a simple asp form which writes to a csv.
    > > > > The code it's based on (from "ASP for Dummies") is:
    > > > >
    > > > > Set peoplefile - _
    > > > > filesys.OpenTextFile( _
    > > > > "c:\inetpub\wwwroot\gb\gbpeople.txt",1)
    > > > >
    > > > > The form is going live soon, and I'd like just a dash of due diligence
    > > > > in terms of security. I tried using a relative link to the

    > gbpeople.txt
    > > > > file which didn't work. Is there a better way around this without
    > > > > reinventing?
    > > > >
    > > > > Much thanks,
    > > > >
    > > > > Scott
    > > > >

    > >
    > > I should have mentioned that I'm a hack cluebie....
    > > It looks like exactly what I'm looking for, but I'm not sure how to
    > > combine the two.
    > >
    > > My code looks like:
    > > <%...
    > > Dim filesys, mgrfile
    > > Set filesys = CreateObject("Scripting.FileSystemObject")
    > > Set mgrfile = _
    > > filesys.OpenTextFile(_
    > > "C:\Inetpub\yadayada\contestants.csv",_
    > > 8, true)
    > > ...%>
    > >
    > > Microsoft's:
    > > <%=
    > > Server.MapPath(Request.ServerVariables("PATH_INFO"))%>
    > >
    > > I figure it's something like
    > > Set mgrfile =
    > > Server.MapPath(Request.ServerVariables("contestants.csv", 8, true))?
    > >
    > > Can I get an amen?
    > >
    > > Thanks again.
    > >
    > > Scott
    > >


    I wound up using your guidance and getting a little help. For the sake
    of reference, I used:

    Set sampleObject =
    otherObject.CreateTextFile((Server.MapPath("folder/file_name.txt")),
    True)

    It's working. Thanks for your help.

    Scott
    Scott Gordo, Mar 15, 2006
    #6
    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. Ben
    Replies:
    8
    Views:
    1,811
    Patrice
    Aug 19, 2004
  2. Kenneth McDonald
    Replies:
    2
    Views:
    353
    Thomas Guettler
    Jun 21, 2004
  3. Tintin92
    Replies:
    1
    Views:
    1,661
    Andrew Thompson
    Feb 14, 2007
  4. jliu66
    Replies:
    0
    Views:
    482
    jliu66
    Oct 19, 2007
  5. Li Chen
    Replies:
    18
    Views:
    636
    Azmi Farih
    Mar 23, 2010
Loading...

Share This Page