<?php
$filename = $_FILES["myfile"]["name"];
$filesize = $_FILES["myfile"]["size"];
$tmp_name = $_FILES["myfile"]["tmp_name"];
     
$extensions = array('.jpg', '.jpeg', '.gif', '.png', '.bmp');
$getExt = strtolower(strrchr($filename, '.'));
$getfileSize = round($filesize / 2048, 1);
$max_size = '1024'; // in KB
     
//image storage path
$path = "images/" . $filename;
     
if( !empty( $filename ) ){
         
    if(in_array( $getExt, $extensions)){
        if( $getfileSize < $max_size ){
            //echo $getfileSize . ' KB';
            move_uploaded_file($tmp_name, $path);
            echo '<img src="custimages/'.$filename.'" />';
        }
        else{
            echo 'Filesize is large ('.$getfileSize.' KB) that should be less then 1024 KB';
        }
    }
    else{
        echo 'File not Supported!';
    }
}
?>