Upload .txt and keep formating

Posted by s2xi on Stack Overflow See other posts from Stack Overflow or by s2xi
Published on 2011-01-13T00:47:39Z Indexed on 2011/01/13 0:53 UTC
Read the original article Hit count: 183

Filed under:
|

I have been trying to upload a .txt to my server via a simple php script I made. Everything seems to uploaded correctly, if I open the .txt in Dreamweaver I can see all the formatting is still in tact with spaces and paragraph breaks.

The problem I have is when I try to open that file with PHP and import the contents onto my site. I'm not using an editor right now, just a simple div where the contents are echoed.

I don't have much experience with uploading/downloading using PHP. Am I not using a command to handle the file contents and keep the initial formatting?

In the end I want the user to upload a file, and have PHP read the file and extract certain elements from it based on the number of spaces between paragraph breaks and such.

I was able to actually echo the .txt using URLENCODE() which kept the formatting and made all my spaces +'s. Thats the closes I got, but the original file isn't uploaded in the format so I can't do a count for +'s and select x characters after the last +.

Hmmm, if someone knows of a script already available that can do this or similar to with me just tweaking that would be awesome.

© Stack Overflow or respective owner

Related posts about php

Related posts about edittext