another permission denied error

Discussion in 'ASP General' started by McTuble, Sep 2, 2005.

  1. McTuble

    McTuble Guest

    So I'm new to ASP and set it up on my computer and just want a simple text
    based guestbook where it just adds your entry to the end of the textfile and
    to display just displays the contents of the textfile. So displaying the
    contents is not the problem. Here is the code

    <html>
    <body>
    <% Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8
    %>

    <FORM action="signBook.asp" method="GET">
    name:<INPUT TYPE="text" NAME="name">
    message:<INPUT TYPE="text" NAME="message">
    <INPUT TYPE="submit">
    </FORM>
    <%
    n=request.querystring("name")
    m=request.querystring("message")

    if n<>"" And m<>"" then
    set fs = Server.CreateObject("Scripting.FileSystemObject")
    set f = fs.OpenTextFile("guestbook.txt", ForAppending, true)
    f.WriteLine("This line is added to the file.")
    f.Close()
    end if
    if n="" And m="" then
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    Set f=fs.OpenTextFile(Server.MapPath("guestbook.txt"), 1)
    Response.Write(f.ReadAll)
    f.Close()
    end if

    %>
    </body>
    </html>

    I get the Permission denied error on this line -> set f =
    fs.OpenTextFile("guestbook.txt", ForAppending, true)

    I have been all over the internet and tried giving the folders write access
    through the control panel -> administrative tools -> internet information
    services and I've also tried right clicking the folder and clicking on
    properties. Then the security tab. Can anyone help me? It's kinda important
    I get this out of the way. I am using Windows XP Professional with Service
    Pack 2. Thanks guys.
    McTuble, Sep 2, 2005
    #1
    1. Advertising

  2. McTuble

    McKirahan Guest

    "McTuble" <> wrote in message
    news:...
    > So I'm new to ASP and set it up on my computer and just want a simple text
    > based guestbook where it just adds your entry to the end of the textfile

    and
    > to display just displays the contents of the textfile. So displaying the
    > contents is not the problem. Here is the code
    >
    > <html>
    > <body>
    > <% Const ForReading = 1
    > Const ForWriting = 2
    > Const ForAppending = 8
    > %>
    >
    > <FORM action="signBook.asp" method="GET">
    > name:<INPUT TYPE="text" NAME="name">
    > message:<INPUT TYPE="text" NAME="message">
    > <INPUT TYPE="submit">
    > </FORM>
    > <%
    > n=request.querystring("name")
    > m=request.querystring("message")
    >
    > if n<>"" And m<>"" then
    > set fs = Server.CreateObject("Scripting.FileSystemObject")
    > set f = fs.OpenTextFile("guestbook.txt", ForAppending, true)
    > f.WriteLine("This line is added to the file.")
    > f.Close()
    > end if
    > if n="" And m="" then
    > Set fs=Server.CreateObject("Scripting.FileSystemObject")
    > Set f=fs.OpenTextFile(Server.MapPath("guestbook.txt"), 1)
    > Response.Write(f.ReadAll)
    > f.Close()
    > end if
    >
    > %>
    > </body>
    > </html>
    >
    > I get the Permission denied error on this line -> set f =
    > fs.OpenTextFile("guestbook.txt", ForAppending, true)
    >
    > I have been all over the internet and tried giving the folders write

    access
    > through the control panel -> administrative tools -> internet information
    > services and I've also tried right clicking the folder and clicking on
    > properties. Then the security tab. Can anyone help me? It's kinda

    important
    > I get this out of the way. I am using Windows XP Professional with Service
    > Pack 2. Thanks guys.
    >


    Your files are in different locations as
    "guestbook.txt"
    and
    Server.MapPath("guestbook.txt")
    are not the same.

    Try this. Watch for word-wrap.

    <%@ Language="VBScript" %>
    <% Option Explicit
    '*
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8
    '*
    Dim n
    n = request.querystring("name")
    Dim m
    m = request.querystring("message")
    '*
    Dim dat
    Dim fso
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Dim otf
    Dim txt
    txt = Server.MapPath("guestbook.txt")
    '*
    if n<>"" And m<>"" then
    Set otf = fso_OpenTextFile(txt, ForAppending, true)
    otf.WriteLine("This line is added to the file.")
    else
    Set otf = fso_OpenTextFile(txt, ForReading)
    dat = Replace(otf.ReadAll,vbCrLf,"<br>")
    Response.Write(dat)
    end if
    '*
    Set otf = Nothing
    Set fso = Nothing
    %>
    <html>
    <body>
    <FORM action="guestbook.asp" method="GET">
    name: <INPUT TYPE="text" NAME="name">
    message: <INPUT TYPE="text" NAME="message">
    <INPUT TYPE="submit">
    </FORM>
    </body>
    </html>
    McKirahan, Sep 2, 2005
    #2
    1. Advertising

  3. Hi McTuble,

    After you did the "right clicking the folder and clicking on properties.
    Then the security tab," what did you do? Did you modify the permissions at
    all? IN an typical setup, IUSR_name_of_your_computer will need read/write
    permissions to the file you're trying to modify.

    Ray at work

    "McTuble" <> wrote in message
    news:...

    > I get the Permission denied error on this line -> set f =
    > fs.OpenTextFile("guestbook.txt", ForAppending, true)
    >
    > I have been all over the internet and tried giving the folders write
    > access through the control panel -> administrative tools -> internet
    > information services and I've also tried right clicking the folder and
    > clicking on properties. Then the security tab.
    Ray Costanzo [MVP], Sep 2, 2005
    #3
  4. McTuble

    McTuble Guest

    Thanks McKirahan it was exactly that. I just changed set f =
    fs.OpenTextFile("guestbook.txt", ForAppending, true) to set f =
    fs.OpenTextFile(Server.MapPath("guestbook.txt"), ForAppending, true). Thanks
    as well to you Ray for trying to help me. I had indeed changed the file
    permissions. I was just explaining that I used both of those methods to do
    so. Also thanks for the quick response.
    McTuble, Sep 2, 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. Taishi

    Permission denied error 2nd Post

    Taishi, Feb 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,735
    Taishi
    Feb 11, 2004
  2. Mr.KisS
    Replies:
    1
    Views:
    17,676
    Teemu Keiski
    Jul 9, 2004
  3. Jordan
    Replies:
    0
    Views:
    670
    Jordan
    Dec 10, 2004
  4. Tim Golden
    Replies:
    0
    Views:
    956
    Tim Golden
    Aug 28, 2008
  5. PM Creyghton

    Another Permission Denied error

    PM Creyghton, Sep 6, 2004, in forum: Javascript
    Replies:
    2
    Views:
    107
    PM Creyghton
    Sep 7, 2004
Loading...

Share This Page