faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

18 of 23 people (78%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I read data from a windows .txt file and display it on a web-page ?

Feb 24th, 2008 00:14
dman, Tim Dorr, Daniel Platon, http://www.ttnr.org


Either:
$filename = "c:\files\file.txt";
$fd = fopen ($filename, "rt");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
where $contents is a string containing the contents of the file 
$filename
OR
readfile("c:\files\file.txt):
which will take the file and output it directly to the page.