Currently my code can upload an image if a valid image is selected. What I need is if no image is selected, a default/alternative image will be uploaded instead. here is my code-
if(isset($_POST['btnSave'])){
$imgName1 = $_FILES['image1']['name'];
$imgTmp1 = $_FILES['image1']['tmp_name'];
$imgSize1 = $_FILES['image1']['size'];
$imgExt1 = strtolower(pathinfo($imgName1, PATHINFO_EXTENSION));
$allowExt1 = array('jpeg', 'jpg', 'png', 'gif',''); //'' will allow empty value, otherwise will get error message
$userPic1 = $carreg."-".$imgName1;
if(in_array($imgExt1, $allowExt1)){
if($imgSize1 < 7000000){
move_uploaded_file($imgTmp1 ,$upload_dir.$userPic1);
}else{
$errorMsg = 'Image too large';
}
} else {
$errorMsg = 'Please select a valid image (Approved extensions are jepg, jpg, png and gif)';
}