Page 1 of 1

Managing textfiles

Posted: Tue Sep 07, 2010 12:32 pm
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

Re: Managing textfiles

Posted: Tue Sep 07, 2010 1:51 pm
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

Re: Managing textfiles

Posted: Thu Sep 09, 2010 5:53 am
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.

Re: Managing textfiles

Posted: Thu Sep 09, 2010 4:07 pm
by Jonah Bron
Post your code and I'll show you what I'm talking about.

Re: Managing textfiles

Posted: Thu Sep 09, 2010 5:57 pm
by Benjamin
:arrow: Moved to PHP - Code