Re: Question reading a file
| From: | Ashley Sheridan | Date: | Thu, 27 Oct 2011 20:53:52 +0000 |
| Subject: | Re: Question reading a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315461@lists.php.net to get a copy of this message | ||
On Thu, 2011-10-27 at 15:25 -0400, Tedd Sperling wrote:
> 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
>
>
>
>
>
>
This might sound silly, but is it because it's being interpreted
somehow? I could understand the HTML going a little weird because of
this, not sure about the PHP, would depend what was trying to interpret
it...
--
Thanks,
Ash
http://www.ashleysheridan.co.uk