<?php
if($_POST){
$imagentipo=$_FILES['imagen']['type'];
$check=array("image/gif","image/jpeg","image/png");
if(in_array($imagentipo,$check)){
$imagen=$_FILES['imagen']['name'];
$temp=$_FILES['imagen']['tmp_name'];
move_uploaded_file($temp,$imagen);
}
}
?>
<html>
<body>
<form action=test.php method=post enctype=multipart/form-data>
<img src="<?php echo $imagen ?>" width=50 height=50><br>
<input type=file name=imagen accept="image/*"><br>
<input type=submit name=lol>
</form>
</body>
</html>
This code only allows .jpg .gif .png files to be uploaded; however, that can be bypassed with tamper data. Any ways to prevent this?