Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: external text

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    external text

    is it possible to insert the text of a notepad file into a paragraph?

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Posts
    565
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes it is... The way I would do it is to use something like FSO (if you are coding with ASP for example). But FSO have some downsides so I would recommend (if you can do it of course) that you store the texts in a db. It will also make things easier for you in terms of updates etc...
    Last edited by jeskel; 01-10-2004 at 02:10 PM.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do you need it to be read every time or just the once?

    For reading off a txt file on the server you'll need to use a server side language - PHP is the favourite around here but i depends what you have available.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #4
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?php echo "<![CDATA[" . implode('', file('%path to file%')) . "]]>" ?>

    Naturally replace %path to file% with the path to your file.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are using PHP 4.3.0+ then implode('',file($filename)) is not the best way to read a file into a string
    file_get_contents($filename) is a much simpler way of loading a file into a string.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i use HTML

    I just want to insert the text of a notpad file into a div element

    thats all, and i dont know anything about php fso or and of the other stuff



    thanks for ur help

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cant be done simply - needs some sort of server side code. Just copy and paste it manually. Cant be that difficult.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #8
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by ReadMe.txt
    If you are using PHP 4.3.0+ then implode('',file($filename)) is not the best way to read a file into a string
    file_get_contents($filename) is a much simpler way of loading a file into a string.
    Sorry, I gave up on file_get_contents because it didn't work and I couldn't be bothered to debug it. Didn't think of using it in this situation.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for all ur help

  • #10
    Regular Coder
    Join Date
    Aug 2003
    Posts
    565
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you got it. If you're using PHP you already have the needed code to cut/paste and if you're using ASP you can do this:

    Code:
    <%
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    
    Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
    Response.Write(f.ReadAll)
    f.Close
    
    Set f=Nothing
    Set fs=Nothing
    %>
    good luck!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •