You must upload webshell and cat /flag

<html>
<head>
<title>Challenge 43 RevengE</title>
</head>
<body>
<hr>
You must upload webshell and cat <b>/flag</b>
<hr>
<?php
  
if(isset($_FILES['file'])){
    
$type $_FILES['file']['type'];
    
$name $_FILES['file']['name'];
    if(!
$type) { exit("type not detected"); }
    if(
preg_match("/\.\.|\/|\\\|\.htaccess/",$name)) exit("dont do that");
    if(
preg_match("/text\/|application\/octet-stream/i",$type)) exit("wrong type");
    
$image = new Imagick();
    
$image->readImage($_FILES['file']['tmp_name']);
    
$image->resizeImage(500500imagick::FILTER_GAUSSIAN10);
    
$image->writeImage("./upload/".$name);
    echo 
"Done!<br><br><a href=./upload/{$name}>./upload/{$name}</a>";
  }
?>
<form method=post enctype="multipart/form-data" action=index.php>
<input name=file type=file><input type=submit>
</form>
<hr><?php highlight_file(__FILE__); ?>
</body>
</html>