Help Needed: HTML & Text files

Posted on 2006-05-08
Last Modified: 2013-11-18
Dear All,

Im am currently doing a website for a friend.
Im not really very good at the programming aspects of things and so I have stumbled upon a little challenging bump in the road.

Due to the fact that my site needs one simple page that is updated regularly in terms of text information, and I haven't really learn't advanced stuff like ASP and such:

- Would anyone here know of how to make your html page read the text from a .txt file that would be stored together with all of the pages on the server. This way, all my friend needs to do is every now and then change the text in the text file and upload the new file after changes have been made.  Somehow like the html file that is linked to it grabs the text from this one .txt file and displays it. (it would only be a relation between one page and one .txt file)

Any help on this would be much appreciated.

Thank you : ) - Excitedly awaiting any help.

Question by:siamesefish
    LVL 1

    Accepted Solution

    Unfortunately, I don't think there is any way to do this without using server-side scripting such as asp.  Although, its not going to be as difficult as you think.

    1) Give the file a .asp extension.
    2) Insert (and modify) the following code for where you wish to insert the text on the page:

    Dim objFSO, objText
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objText = objFSO.OpenTextFile(Server.MapPath("YourFile.txt"))

    Do While Not objText.AtEndOfStream

    Set objText = Nothing
    Set objFSO = Nothing

    Good luck

    Do you have the asp compiler enabled on the server?
    LVL 25

    Expert Comment

    Or if you have a Java-enabled server, it's as simple as this:

    <%@ include file="myfile.txt" %>

    An alternative solution would be to embed a frame into the page, which loads the txt file, such as:

    <iframe src="myfile.txt"></iframe>

    But this most probably is not what you're looking for ..
    LVL 95

    Expert Comment

    by:Lee W, MVP
    Very easy - server side includes.
    Read the section here on Server Side Includes:

    Author Comment

    Thanks for all the comments! Im giving hairy mike the points cause he was the first.
    but i appreciate all the rest very much. Thanks once again.

    LVL 25

    Expert Comment

    Well, you should really accept the comment that helped the most (not the first to post).
    Either way, you _can_ also split the points..

    (A little too late now, but next time ......)

    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Join & Write a Comment

    Suggested Solutions

    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now