[wd_asp elements=’search’ ratio=’100%’ id=1]

Allowed file extension in upload form

14th September 2016

Php - Miscellaneous

php codehaven

In the receiving file upload form, change source filename to lowercase then check extensions.


$uploadimage = $_FILES['userfile']['name'];
$upload_image = strtolower($upload_image);

$allowed = array('gif','png' ,'jpg');

$ext = pathinfo($upload_image, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed) ) {
// echo 'error';
die("Nope!");
}