• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

Help Needed: HTML & Text files

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.

Regards
EJQ
0
siamesefish
Asked:
siamesefish
1 Solution
 
HairyMikeCommented:
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
    Response.Write(objText.ReadLine)
    Response.Write("<br>")
Loop

objText.Close
Set objText = Nothing
Set objFSO = Nothing
%>

Good luck

Do you have the asp compiler enabled on the server?
0
 
InteractiveMindCommented:
Or if you have a Java-enabled server, it's as simple as this:

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


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 ..
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Very easy - server side includes.
Read the section here on Server Side Includes:
http://www.boutell.com/newfaq/creating/include.html
0
 
siamesefishAuthor Commented:
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.

EJQ
0
 
InteractiveMindCommented:
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 ......)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now