
-----------------------------------
da_foz
Fri Oct 01, 2004 7:48 pm

Dispay text files
-----------------------------------
Ok, here is what I want to do.

I have a directory with a bunch of *.txt files in it.  What I want is to generate a list of all the file names, and places them on a page.  The list will be links, so that when you click on one of them, the *.txt file will be displayed.

Now the part I am having trouble with.  What I want is for the *.txt file to be displayed on the same page as the the list of files, but underneath. (ie, like this http://www.redclaw.ca/funnypics.php ).

I got it working for the pics page, but I can't get it working for the 'text jokes'.

Here is the code I am using for the pics page:






The problem I'm having modifying this code is that I think I will have to read in the *.txt line by line and then output it, and I just can't get it to work.  I've spent much time on the PHP website working on this.  Any help would be great.

Thanks.

-----------------------------------
wtd
Fri Oct 01, 2004 8:02 pm


-----------------------------------
What about using include() to insert the text of the document?



-----------------------------------
da_foz
Fri Oct 01, 2004 8:11 pm


-----------------------------------
Ok, I tried that here:
http://www.redclaw.ca/textjokes.php

Try clicking on one of the options and see so that you can see the error.





-----------------------------------
wtd
Fri Oct 01, 2004 8:18 pm


-----------------------------------
Try using the full path to that directory.

-----------------------------------
rdrake
Fri Oct 01, 2004 8:24 pm


-----------------------------------
Does work?

-----------------------------------
da_foz
Fri Oct 01, 2004 8:26 pm


-----------------------------------
Does work?

That generate this error:
Warning: main(): Unable to access /jokes/ in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134

Warning: main(/jokes/): failed to open stream: No such file or directory in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134

Warning: main(): Failed opening '/jokes/' for inclusion (include_path='.:/php/includes:/usr/share/php:/usr/share/pear') in /home/virtual/site118/fst/var/www/html/textjokes.php on line 134


Oh, and I changed the dir 'funPics' to 'jokes' which is what it should be.

-----------------------------------
da_foz
Fri Oct 01, 2004 8:27 pm


-----------------------------------
I know I have access to the dir as if I try going to it directly I get it.

http://www.redclaw.ca/jokes/City_Boy.txt

-----------------------------------
da_foz
Fri Oct 01, 2004 8:28 pm


-----------------------------------
Try using the full path to that directory.

Did not seem to change anything.

-----------------------------------
Blade
Sat Oct 02, 2004 3:07 pm


-----------------------------------
okay. there are two ways i'd do this: include the file, or use an iframe.
including i dont like because when you include the text file, it usually doesnt show the new lines where they're supposed to be. using an iframe does that, and it lets you scroll down. i made 2 test pages and you can check them out here.

include:

