-4

I'm working my way through input filtering (files) and I just discovered that if you rename a .jpg file into a .png file the MIME type will change automatically to fit the extension. So I was thinking, in that case what's the point of checking the MIME type ? (I know that it can be changed by the client which is a serious drawback too, but I'm checking it "for fun")

teum
  • 125
  • 3
  • 12

1 Answers1

1

Well, for one, the content of the file doesn't change; so if you actually check the type yourself (instead of blindly trusting user-submitted data), you'll see it's just a misnamed file.

As for the user-supplied MIME-type, checking that is an exercise in futility, yes.

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • You have perfectly understood AND answered my question (even if it is not perfectly phrased) so I don't really understand the -5, but I don't really care about it either as I came for an answer. Maybe you can tell me how to "check the type [myself]" but you will certainly ask me to create a new question instead. – teum Nov 25 '11 at 17:04
  • @teum: I won't :) I believe this has already been answered here before, check the "Related" sidebar on the right: first two links are just what you're looking for. http://stackoverflow.com/questions/310714/how-to-check-file-types-of-uploaded-files-in-php and http://stackoverflow.com/questions/481743/how-can-i-determine-a-files-true-extension-type-programatically – Piskvor left the building Nov 25 '11 at 17:59