I am new to php. I have searched for a solution to this problem for over 1 hour but could not find an answer.
Example situation: Check uploaded file extension & size and echo out errors for each failure (if any)(stopping at first failure).
Code so far:
$allowedfiletypes = array("image/jpg","image/jpeg","image/png");
if((!in_array($filetype, $allowedfiletypes))) {
echo "Error, disallowed file type.";
} elseif($filesize > 1048576) {
echo 'Filesize too large';
} else {
move_uploaded_file($filetmpname, $uploaddir."/".$filename);
echo 'The file has the following properties:'." ".$filename.", ".$filesize."kb, ".$filetype.".".'<br><br>';
echo ' The file is stored in'.$uploaddir.$filename;
}
But this does not work if the file size is over the specified limit.
How can i do if() {echo 'error1';} || if {echo 'error2'.} else {}
?