I'm having a little trouble with formatting in uploaded files. Basically an administrator can upload article files in a *.txt format. I then store the path of the textfile in a database so that I can access and display it as follows:
$fop = fopen($pathname); // open the file stream
$content = strip_tags(file_get_contents($pathname)); // get the contents of the uploaded article
echo 'There was an error opening the file';
fclose($fop); // close the file stream
echo "$content"; // display the article
// $pathname is just a pathname to the file
The trouble is, when I display the file, I have no formatting at all. I realise *.txt doesn't have proper formatting but surely I should see some line breaks between the paragraphs?
How else could I do this? I don't want to allow the user to upload HTML files as I use the strip_tags() function to remove any tags in the file (else it could be a security risk as others could execute malicious PHP code or such like).
I've tried using RTF files but then I can see the formatting which the word processor puts in and it looks very ugly.
"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"