I'm working on this script taken over the network to upload files to a server folder. The script works fine but it only allows jpeg images with a weight less than 2 mb. I modified the code by adding other formats to load, it works, unfortunately no longer takes into account the weight limit (2 mb). Where am I wrong? Thank you (I attach the original and edited script)
Originale script
<?php
require('connect.php');
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$extension = substr($name, strpos($name, '.') + 1);
$max_size = 2000000;
if(isset($name) && !empty($name)){
 if(($extension == "jpg" || $extension == "jpeg") && $type == "image/jpeg" && $extension == $size<=$max_size){
  $location = "uploads/";
        
       if(move_uploaded_file($tmp_name, $location.$name)){
   $query = "INSERT INTO `upload` (name, size, type, location) VALUES ('$name', '$size', '$type', '$location$name')";
          $result = mysqli_query($connection, $query);
   
   $smsg = "Caricamento riuscito."; 
  }else{
   $fmsg = "Caricamento fallito";
  }
 }else{
  $fmsg = "Il file deve avere una dimesione inferiore a 2 mb e in formato jpeg";
 }
}else{
 $fmsg = "Seleziona un file";
}
?>
<html>
<head>
 <title>File Upload Script Using PHP MySQL</title>
 
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<link rel="stylesheet" href="styles.css" >
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<?php //echo $name; ?>
<?php //echo $size; ?>
<?php //echo $type; ?>
<?php //echo $tmp_name; ?>
      <form class="form-signin" method="POST" enctype="multipart/form-data">
      <?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
      <?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>      
        <h2 class="form-signin-heading">Upload File</h2>
   <div class="form-group">
     <label for="exampleInputFile">File input</label>
     <input type="file" name="file" id="exampleInputFile">
     <p class="help-block">Carica file in formato JPEG inferiori a 2 MB</p>
   </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">carica</button>
      </form>
</div>
</body>
</html>Codice modificato
if(isset($name) && !empty($name)){
 if(($extension == "jpg" || $extension == "jpeg") && $type == "image/jpeg" || $type == "image/png " || $type == "image/gif" && $extension == $size<=$max_size){
  $location = "uploads/";I guess I miss the syntax, can anyone help me?
 
    