PHP mime_content_type Alternatives In Debian 5.0

We were called in to help someone with a failing file upload feature on a PHP website.

It turned out that we’d recently upgraded their server to debian 5.0 and the mime_content_type() PHP function was no longer available.

This isn’t a serious bug really, because the function has been deprecated (old PHP lives forever, but not so function definitions) for some time. Debian bug #491033 gives the details.

We put together a fairly quick fix using shell_exec() to call the file command (with the usual checks to avoid someone poisoning the shell – which shouldn’t happen because it’s only called on uploaded temporary filenames, but why risk it?). We could have used finfo_file but that’s not yet packaged for debian, so is it worth the cost of having unpackaged PHP classes around?

This entry was posted in Web Development and tagged , , , , , , , , . Bookmark the permalink.

2 Responses to PHP mime_content_type Alternatives In Debian 5.0

Leave a Reply

Your email address will not be published.