Managing textfiles

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
carcaix
Forum Newbie
Posts: 12
Joined: Sun Aug 29, 2010 9:33 am

Managing textfiles

Post by carcaix »

Hello,

In my aplication registered users can generate text files when they do an specific action. Then they also have a section to look for these text files and i do not know how to show each text file in the section. I don't want to show all the text in these files in the section i only want to show haw many of this files are there and with the possibility to click on them.


For instance

Section:
Textfile1 -> when click on it show the document and if it's possible with html and css format
Textfile2
Textfile3


User Folder:
Textfile1
Textfile2
Textfile3
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Managing textfiles

Post by Jonah Bron »

Get the list of files:
http://us3.php.net/manual/en/function.opendir.php

If you want to have HTML and CSS, you'll have to, instead of linking to somefile.txt, you'll have to link to something like viewfile.php?f=somefile.txt , then viewfile.php will open up $_GET['f'] with file_get_contents()

http://us3.php.net/manual/en/function.f ... ntents.php
carcaix
Forum Newbie
Posts: 12
Joined: Sun Aug 29, 2010 9:33 am

Re: Managing textfiles

Post by carcaix »

Thanks Jonah,

NowI am able to show the files which are in the directory. I manage to put a link (and input type="submit") with a specific value that when the user click on it it shows the textfile. But using file_get_contents() it doesn't follow the same rules like spaces and end lines. And I want to show the document with format css and html how can I do that?

In your reply I don't really understand this:

you'll have to link to something like viewfile.php?f=somefile.txt , then viewfile.php will open up $_GET['f'] with file_get_contents()

How I link to this page -> viewfile.php?f=somefile.txt. It seems to me like chinese I don't understand nothing.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Managing textfiles

Post by Jonah Bron »

Post your code and I'll show you what I'm talking about.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Managing textfiles

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply