Textbox editing...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ketta

    Textbox editing...

    I know how to read a file system object and output it to the browser page.
    The desired result would be to put that file into a textbox on the screen
    for a user to modify and then write the file back to the file system. The
    concept seems simple enough, read the text file into a variable then some
    magic asp will put it into a textbox value, then somehow take that value and
    write the file. I know how to write files to the system as well. I am
    missing a key piece.. any ideas?

    Thanks,
    Ketta


  • Ray at

    #2
    Re: Textbox editing...

    Alright, you have the file in a textbox already, so once the user submits
    the file, take the request.form("t hatTextbox"), create an FSO object, and
    overwrite the existing file with the contents from that textbox.

    Ray at home

    "Ketta" <no@post.net> wrote in message
    news:%23cS6V3Op DHA.3040@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > I know how to read a file system object and output it to the browser page.
    > The desired result would be to put that file into a textbox on the screen
    > for a user to modify and then write the file back to the file system. The
    > concept seems simple enough, read the text file into a variable then some
    > magic asp will put it into a textbox value, then somehow take that value[/color]
    and[color=blue]
    > write the file. I know how to write files to the system as well. I am
    > missing a key piece.. any ideas?
    >
    > Thanks,
    > Ketta
    >
    >[/color]


    Comment

    • Ketta

      #3
      Re: Textbox editing...

      Well thanks for that part, that will definately help me. But I still do not
      have the file in a textbox. It just outputs it to the screen. This is my
      code for reading the file and putting it on the screen. I'm a total noob
      with ASP btw. This is probably just annoying to have someone like me asking
      for help. Now all I need is the code below to output to a textbox....
      somehow.


      <%
      set fso = server.createob ject("Scripting .FileSystemObje ct")
      set fs = fso.openTextFil e("textfile.txt ",1,true)
      response.write replace(replace (fs.readall,"<" ,"<"),vbCrLf,"< br>")
      fs.close: set fs = nothing: set fso = nothing
      %>

      Thank you
      Ketta

      "Ray at <%=sLocation% >" <myfirstname at lane 34 . komm> wrote in message
      news:eZKA8HQpDH A.1672@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Alright, you have the file in a textbox already, so once the user submits
      > the file, take the request.form("t hatTextbox"), create an FSO object, and
      > overwrite the existing file with the contents from that textbox.
      >
      > Ray at home
      >
      > "Ketta" <no@post.net> wrote in message
      > news:%23cS6V3Op DHA.3040@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > I know how to read a file system object and output it to the browser[/color][/color]
      page.[color=blue][color=green]
      > > The desired result would be to put that file into a textbox on the[/color][/color]
      screen[color=blue][color=green]
      > > for a user to modify and then write the file back to the file system.[/color][/color]
      The[color=blue][color=green]
      > > concept seems simple enough, read the text file into a variable then[/color][/color]
      some[color=blue][color=green]
      > > magic asp will put it into a textbox value, then somehow take that value[/color]
      > and[color=green]
      > > write the file. I know how to write files to the system as well. I am
      > > missing a key piece.. any ideas?
      > >
      > > Thanks,
      > > Ketta
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Ray at

        #4
        Re: Textbox editing...


        "Ketta" <no@post.net> wrote in message
        news:OHE3I4VpDH A.488@tk2msftng p13.phx.gbl...[color=blue]
        > Well thanks for that part, that will definately help me. But I still do[/color]
        not[color=blue]
        > have the file in a textbox. It just outputs it to the screen. This is my
        > code for reading the file and putting it on the screen. I'm a total noob
        > with ASP btw. This is probably just annoying to have someone like me[/color]
        asking[color=blue]
        > for help.[/color]

        If I were annoyed, I wouldn't use newsgroups. :]
        [color=blue]
        > Now all I need is the code below to output to a textbox....
        > somehow.
        >
        >
        > <%
        > set fso = server.createob ject("Scripting .FileSystemObje ct")
        > set fs = fso.openTextFil e("textfile.txt ",1,true)
        > response.write replace(replace (fs.readall,"<" ,"<"),vbCrLf,"< br>")
        > fs.close: set fs = nothing: set fso = nothing
        > %>
        >[/color]

        You can just server.execute the contents of the file, i.e.

        http://yoursite/filemod.asp?filename=file.txt :
        <%
        sFilename = Request.Queryst ring("filename" )
        %>

        <html>
        <form method="post" action="filemod p.asp">
        <input name="filename" value="<%=sFile name%>" type="hidden">
        <textarea name="fileConte nts" style="width: 500px; height: 800px;"><%
        Server.Execute sFilename %></textarea>
        <input type="submit">
        </form>



        http://yoursite/filemodp.asp :
        <%
        Dim sFilename, sContents
        sFilename = Request.Form("f ilename")
        sContents = Request.Form("f ileContents")
        If sFilename <> "" Then
        Set oFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
        Set oFile = oFSO.CreateText File(Server.Map Path(sFilename) , True)
        oFile.Write sContents
        oFile.Close
        Set oFile = Nothing
        Set oFSO = Nothing
        End If

        Response.Redire ct "filemod.asp?fi lename=" & sFilename
        %>


        Play around with that to see what I mean. But, what you'll want to do first
        is create a file named "file.txt" throw a few characters into it, and then
        load up the filemod.asp page with the ?filename=file. txt querystring. This
        sample has no handling of errors for empty or non-existant files.

        Ray at work





        Comment

        • Chris Hohmann

          #5
          Re: Textbox editing...

          "Ketta" <no@post.net> wrote in message
          news:OHE3I4VpDH A.488@tk2msftng p13.phx.gbl...[color=blue]
          > Well thanks for that part, that will definately help me. But I still[/color]
          do not[color=blue]
          > have the file in a textbox. It just outputs it to the screen. This[/color]
          is my[color=blue]
          > code for reading the file and putting it on the screen. I'm a total[/color]
          noob[color=blue]
          > with ASP btw. This is probably just annoying to have someone like me[/color]
          asking[color=blue]
          > for help. Now all I need is the code below to output to a textbox....
          > somehow.[/color]

          Wrap the file content in textarea tags like so:

          <%
          set fso = server.createob ject("Scripting .FileSystemObje ct")
          set fs = fso.openTextFil e("textfile.txt ",1,true)
          Response.Write "<textarea name='myTextAre a' cols='80' rows='10'>"
          Response.Write fs.readall
          Response.Write "</textarea>"
          fs.close: set fs = nothing: set fso = nothing
          %>

          HTH
          -Chris Hohmann

          P.S. Your question was not annoying and you don't need to apologize for
          being new to ASP. Everyone was once. :) Hope to hear from you again.


          Comment

          • Chris Hohmann

            #6
            Re: Textbox editing...

            "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
            news:O$IcuFWpDH A.2964@tk2msftn gp13.phx.gbl...
            [color=blue]
            > You can just server.execute the contents of the file, i.e.
            >
            > http://yoursite/filemod.asp?filename=file.txt :
            > <%
            > sFilename = Request.Queryst ring("filename" )
            > %>
            >
            > <html>
            > <form method="post" action="filemod p.asp">
            > <input name="filename" value="<%=sFile name%>" type="hidden">
            > <textarea name="fileConte nts" style="width: 500px; height: 800px;"><%
            > Server.Execute sFilename %></textarea>
            > <input type="submit">
            > </form>[/color]

            This introduces a significant security hole in the system since it
            allows the end user to post/execute code of their choosing. I would
            stick with using the FSO.

            -Chris Hohmann


            Comment

            • Ray at

              #7
              Re: Textbox editing...

              That is quite true.

              Ray at work

              "Chris Hohmann" <nospam@thankyo u.com> wrote in message
              news:%23eXJoYWp DHA.2416@TK2MSF TNGP10.phx.gbl. ..[color=blue]
              > "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
              > news:O$IcuFWpDH A.2964@tk2msftn gp13.phx.gbl...
              >[color=green]
              > > You can just server.execute the contents of the file, i.e.
              > >
              > > http://yoursite/filemod.asp?filename=file.txt :
              > > <%
              > > sFilename = Request.Queryst ring("filename" )
              > > %>
              > >
              > > <html>
              > > <form method="post" action="filemod p.asp">
              > > <input name="filename" value="<%=sFile name%>" type="hidden">
              > > <textarea name="fileConte nts" style="width: 500px; height: 800px;"><%
              > > Server.Execute sFilename %></textarea>
              > > <input type="submit">
              > > </form>[/color]
              >
              > This introduces a significant security hole in the system since it
              > allows the end user to post/execute code of their choosing. I would
              > stick with using the FSO.
              >
              > -Chris Hohmann
              >
              >[/color]


              Comment

              Working...