note 69735 added to function.getimagesize

From: Date: Mon, 18 Sep 2006 22:50:56 +0000
Subject: note 69735 added to function.getimagesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-117298@lists.php.net to get a copy of this message
If you're not doing any error checking and are expecting a user to upload an image.. it can pass! Even if it's not an image. Basic error checking would look like this <?php if(!$img_info = getimagesize($some_image)) { die('You did not upload an image!'); } ?> However, this will generate a warning, so use of the error supressing operator is advised. <?php if(!$img_info = @getimagesize($some_image)) { die('You did not upload an image!'); } ?> Seems elementary to some, but I remember this getting me back in the day, when users could upload straight text files to my database. (i've since learned better security.. heh ;)) Hope that helps a few of the newbies out there. Good luck! ---- Server IP: 216.194.113.175 Probable Submitter: 65.29.93.164 ---- Manual Page -- http://www.php.net/manual/en/function.getimagesize.php Edit -- https://master.php.net/note/edit/69735 Del: integrated -- https://master.php.net/note/delete/69735/integrated Del: useless -- https://master.php.net/note/delete/69735/useless Del: bad code -- https://master.php.net/note/delete/69735/bad+code Del: spam -- https://master.php.net/note/delete/69735/spam Del: non-english -- https://master.php.net/note/delete/69735/non-english Del: in docs -- https://master.php.net/note/delete/69735/in+docs Del: other reasons-- https://master.php.net/note/delete/69735 Reject -- https://master.php.net/note/reject/69735 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117298) next »