note 60480 added to function.image-type-to-extension

From: Date: Sun, 08 Jan 2006 15:23:26 +0000
Subject: note 60480 added to function.image-type-to-extension
Groups: php.notes 
Request: Send a blank email to php-notes+get-101413@lists.php.net to get a copy of this message
at aleksandrs note about mime checking i really hope that piece of code isn't used as some kind of security check for uploading (excluding those which have no value in the switch-case ie), as the mime type in uploading could be very easily changed and btw if you want to get the extension why not just use substr to get all the text after the last dot in the filename to be really sure that the file is really what the mime says? this could be done easily with <?php $filename = "roflhax.pwnage.jpeg"; if (($pos = strrpos($filename, ".")) === FALSE) echo "Error - file doesn't have a dot... weird."; else { $extension = substr($filename, $pos + 1); echo $extension; // will echo "jpeg" } ?> (or you could use pathinfo() or a regex :)) ---- Manual Page -- http://www.php.net/manual/en/function.image-type-to-extension.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60480 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60480&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60480&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101413) next »