Re: How reliable is mime type in $_FILES superglobal.
"NC" <nc@xxxxxxxxx> wrote in message
news:1138657877.599655.215680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> splodge wrote:
>>
>> I am working on a portal, part of which allows users to upload files.
>> Part of the array within $_FILES superglobal gives the mime type for the
>> file. Is this 100% reliable / accurate? If the mime type says the file
>> type is jpeg is it always right?
>
> It depends on your definition of "right"... If I understand correctly,
> MIME type is determined based on the file's extension.
Nope - PHP uses the MIME Magic library to determine the mime type of a file
based on the position of key bytes within the file:
http://uk2.php.net/mime_magic
So you could call an .exe .txt, and it would be picked up as an executable.
> Cheers,
> NC
>
.
Relevant Pages
- Re: How reliable is mime type in $_FILES superglobal.
... splodge wrote: ... > I am working on a portal, part of which allows users to upload files. ... > Part of the array within $_FILES superglobal gives the mime type for the ... If the mime type says the file ... (comp.lang.php) - Re: How reliable is mime type in $_FILES superglobal.
... >I am working on a portal, part of which allows users to upload files. ... >Part of the array within $_FILES superglobal gives the mime type for the ... There's functions that use heuristics to make a decent guess as to the format ... (comp.lang.php) - Re: How reliable is mime type in $_FILES superglobal.
... > I am working on a portal, part of which allows users to upload files. ... > Part of the array within $_FILES superglobal gives the mime type for the ... If the mime type says the file ... converted it to a GD file then back to a jpeg. ... (comp.lang.php) - Re: Can I get the Mime Content Type from a byte array?
... When I get the byte array is there a way to determine the content type from it? ... Or do I need to save in database the content type? ... The MIME type isn't inherent in the byte stream. ... You need to save that meta-data yourself if you want to be able to recover it reliably. ... (microsoft.public.dotnet.languages.csharp) - uploading a pdf
... I'm trying to upload a pdf file using the $_FILES built in array ... It gets stalled at this point and displays the echo ... something in the mime type. ... (comp.lang.php) |
|