This is my upload form:
You should set the max allowed file size more than 5M, then with PHP check if the file size exceed 5M. Make sure your webserver post body size is updated with the new size as well.
Limiting file size based on php ini is not the best solution, because it will limit you. What if you want to check another file not exceed 3MB in another script?
if ($_FILES['fileupload']['size'] > 5242880) // 5242880 = 5MB
echo 'your file is too large';