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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -