Question reading a file
| From: | Tedd Sperling | Date: | Thu, 27 Oct 2011 19:25:16 +0000 |
| Subject: | Question reading a file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-315457@lists.php.net to get a copy of this message | ||
Hi gang:
I have a few questions -- this is my first one.
Please review this link:
http://webbytedd.com/cccc/perms/
This page simply reads the contents of a file of the user's choice and displays the file's
data.
My first question is with regard to reading a file ( fread() ):
If the user picks the PDF file, the [1] First 20 bytes are: %PDF...
If the user picks a JPG file, the [1] First 20 bytes are: ...JFFIF...
If the user picks a GIF file, the [1] First 20 bytes are: GIF89a...
Of course, the above is just reading/echoing the header for each of those files.
Likewise, if the user picks a TXT or CSS file, then [1] First 20 bytes echoed are the first 20
characters of the file.
However, if the user picks a HTML or PHP file, there are no [1] First 20 bytes echoed.
BUT, the ord() and chr() of the bytes ARE indeed collected and can be echoed as shown in statements
[2] and [3].
So, my question is specifically "Why is the data gathered in the variable $content not echoed
for the HTML and PHP files, but is for all other files?"
Please review the code shown.
Cheers,
tedd
_____________________
tedd@sperling.com
http://sperling.com