HTML - Read a text file, edit it and write changes

Kila

New Member
I have a text file that contains a list of email addresses, each on a new line. I want to load this text file using HTML and have the contents displayed. I also want to be able to edit the text file on the webpage and have it write any changes.

This just needs to be very simple, nothing fancy. It has to be HTML or JavaScript. Any Google results generally use PHP.

I'm guessing the writing part might not be possible without using PHP or something, but what about just simply reading the text file and displaying it? What would be the simplest HTML code to do that?

Thanks!
 
Last edited:

chrishirst

Well-Known Member
Staff member
Any Google results generally use PHP.
Webservers use PHP not Google

I'm guessing the writing part might not be possible without using PHP or something
100% correct.

It has to be HTML or JavaScript.
Neither will work, HTML has no scripting and javascript cannot read remote files.

but what about just simply reading the text file and displaying it? What would be the simplest HTML code to do that?
server side includes (SSI).
Provided that your server is setup for SSI on .htm(l) file extensions that is.
 

chrishirst

Well-Known Member
Staff member
Oh! and.

HTML does not display "new lines" from text files, the entries would have to be seperated by a <br> which is an HTML line-break. That could be done with with javascript by inserting line-breaks into the DOM when the page loads, provided you include the text file into an element with a preset ID.
 

Kila

New Member
Thanks for the reply, guess PHP it is!

And the Google comment - I meant when I searched for this question, the only results that were related to what I wanted to do were for PHP!
 

chrishirst

Well-Known Member
Staff member
Aha I see.

If you have PHP available you can simply read in the file contents, pass it through nl2br() and push it out in the data stream. job done.

Just be aware that is this is on a public URL spam bot harvesters will be able to collect the email addresses.
 
Top