Home All Groups Group Topic Archive Search About

asp writes csv WITHOUT complete file path?



Author
14 Mar 2006 3:19 PM
Scott Gordo
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

Author
14 Mar 2006 3:23 PM
Patrice
Server.MapPath ? Where do you want to write this file ? What is the security
risk you are trying to avoid ?

--
Patrice

Show quote
"Scott Gordo" <blubberp***@gmail.com> a écrit dans le message de
news:1142349569.868266.210690@j33g2000cwa.googlegroups.com...
> 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
>
Author
14 Mar 2006 3:29 PM
Slim
have you considered server.mappath()
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp


Show quote
"Scott Gordo" <blubberp***@gmail.com> wrote in message
news:1142349569.868266.210690@j33g2000cwa.googlegroups.com...
>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
>
Author
14 Mar 2006 4:04 PM
Scott Gordo
Slim wrote:
Show quote
> have you considered server.mappath()
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
>
>
> "Scott Gordo" <blubberp***@gmail.com> wrote in message
> news:1142349569.868266.210690@j33g2000cwa.googlegroups.com...
> >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
Author
14 Mar 2006 4:16 PM
Patrice
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" <blubberp***@gmail.com> a écrit dans le message de
news:1142352290.670744.223020@u72g2000cwu.googlegroups.com...
>
> Slim wrote:
> > have you considered server.mappath()
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
Show quote
> >
> >
> > "Scott Gordo" <blubberp***@gmail.com> wrote in message
> > news:1142349569.868266.210690@j33g2000cwa.googlegroups.com...
> > >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
>
Author
15 Mar 2006 2:41 PM
Scott Gordo
Patrice wrote:
Show quote
> 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" <blubberp***@gmail.com> a écrit dans le message de
> news:1142352290.670744.223020@u72g2000cwu.googlegroups.com...
> >
> > Slim wrote:
> > > have you considered server.mappath()
> > >
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/270433db-6a1a-42b1-86fa-9c4ca07b75e1.asp
> > >
> > >
> > > "Scott Gordo" <blubberp***@gmail.com> wrote in message
> > > news:1142349569.868266.210690@j33g2000cwa.googlegroups.com...
> > > >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

AddThis Social Bookmark Button