How do I display "file size is greater than the specified" and "Please upload only Image" message to user? I tried with the below code\[code\]if ($_FILES["file"]["size"] > 2097152) { // if file is larger than we want to allow echo "ERROR: Your file was larger than 2MB in file size.";\[/code\] but that didn't work. \[code\]<form action="" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" ><br><input type="submit" name="submit" value="http://stackoverflow.com/questions/14078496/Submit"></form></body></html> \[/code\]Here is my php code below. It works by adding \[code\]else { echo "Invalid file"; }\[/code\] at the end but i wanted to show individual error to the user...txs\[code\]<?php$allowedExts = array("jpg", "jpeg", "gif", "png");$extension = end(explode(".", $_FILES["file"]["name"]));if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/png")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] < 2097152)&& in_array($extension, $allowedExts)){if ($_FILES["file"]["error"] > 0){echo "Return Code: " . $_FILES["file"]["error"] . "<br>";}else{echo "Upload: " . $_FILES["file"]["name"] . "<br>";echo "Type: " . $_FILES["file"]["type"] . "<br>";echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";if ($_FILES["file"]["size"] > 2097152) { // if file is larger than we want to allowecho "ERROR: Your file was larger than 2MB in file size.";}if (file_exists("upload/" . $_FILES["file"]["name"])){echo $_FILES["file"]["name"] . " already exists. ";}else{move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);echo "your photo has been uploaded successfully!";}}}?> \[/code\]