...

View Full Version : external text



JAVAEOC
01-10-2004, 02:02 PM
is it possible to insert the text of a notepad file into a paragraph?

jeskel
01-10-2004, 02:07 PM
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...

ReadMe.txt
01-10-2004, 02:10 PM
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.

me'
01-10-2004, 02:23 PM
<?php echo "<![CDATA[" . implode('', file('%path to file%')) . "]]>" ?>

Naturally replace %path to file% with the path to your file.

ReadMe.txt
01-10-2004, 03:20 PM
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.

JAVAEOC
01-10-2004, 03:29 PM
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

ReadMe.txt
01-10-2004, 03:35 PM
Cant be done simply - needs some sort of server side code. Just copy and paste it manually. Cant be that difficult.

me'
01-11-2004, 12:40 PM
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.

JAVAEOC
01-11-2004, 12:51 PM
thanks for all ur help :)

jeskel
01-11-2004, 01:43 PM
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:



<%
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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum