Re: How reliable is mime type in $_FILES superglobal.



NC wrote:
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.


Cheers, NC


Thank you for the reply. So, what would happen if i took a file named photo.jpg and changed its name to:


1. photo.xyz

2. photo.gif

Different types of files will require different types of processing so it is very important that I can work out what the file type is.
.




Relevant Pages

  • Re: File extensions are fun
    ... I read it as "You download a JPEG but because the server is misconfigured ... you download test.exe with MIME type set to ... I guess it's a question of whether you trust the extension or the MIME type ...
    (uk.comp.sys.mac)
  • 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)