Php file image upload security -


$filename=$_files['file']['name']; $type=$_files['file']['type']; $extension=strtolower(substr($filename, strpos($filename, '.')+1)); $size=$_files['file']['size'];   if(($extension=='jpg' || $extension=='jpeg') && ($type!='image/jpg' || $type!='image/jpeg')){... 

i have input file, can let user upload jpg/jpeg image only, have check type, extension, size.

  1. however i'm not sure how check if user change extension.(ex. abc.php -> abc.jpg)

  2. any thing else need check before save user's image server?

you can check image exif_imagetype()

http://www.php.net/manual/en/function.exif-imagetype.php

exif_imagetype() reads first bytes of image , checks signature.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -