Problems with multiple upload images

Solution for Problems with multiple upload images
is Given Below:

I have this simple code that I want when a customer clicks on the option 2 IMG
It shows him two input upload image, and when he chooses the number 1 IMG option, only one input upload image appears. And hide 2 input upload option

Please help, how can I do this code in this format I followed and I searched, but I could not do it and I did not find enough explanations about it

<div class="upload-btn-wrapper">
<label for="file" class="btns" id="file-label">
    Upload Image
 </label>
 <input type="file" class="file" action="" name="file" id="file" accept="image/*">
</div>
  <select id="X" name="X">
    <option value="1">1 IMG</option>
    <option value="2">2 IMG</option>
  </select>

his is the php code that works with it

if (isset($_POST["submit"])) {
    
    $allowed_image_extension = array(
        "png",
        "jpg",
        "jpeg",
        "gif"
    );
    $uploadOk = 1;
    
    // Get image file extension
    $file_extension = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
    
    // Validate file input to check if is not empty
    if (! file_exists($_FILES["file"]["tmp_name"])) {
        $uploadOk = 0;
        $response = array(
            "type" => "error",
            "message" => "Choose image file to upload."
        );
    }    // Validate file input to check if is with valid extension
    else if (! in_array($file_extension, $allowed_image_extension)) {
        $uploadOk = 0;
        $response = array(
            "type" => "error",
            "message" => "Upload Valid Images. Only PNG, JPEG, JPG, GIF, Are Allowed."
        );
    }    // Validate image file size
    else if (($_FILES["file"]["size"] > 5000000)) {
        $uploadOk = 0;
        $response = array(
            "type" => "error",
            "message" => "Image Size Exceeds 5MB."
        );
    }  
    
       // Get Ip Cilent For Upload
       $upload_folder = "Uploads/";
       
       // boundary
       $semi_rand = md5(time());
       $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

       // headers for attachment
       $headers .= "nMIME-Version: 1.0n" . "Content-Type: multipart/mixed;n" . " boundary="{$mime_boundary}"";

       // multipart boundary
        $message = "This is a multi-part message in MIME format.nn" . "--{$mime_boundary}n" . "Content-Type: text/plain; charset="iso-8859-1"n" . "Content-Transfer-Encoding: 7bitnn" . $message . "nn";
        $message .= "--{$mime_boundary}n";

       $content="";
       $tmp_path = $_FILES["file"]["tmp_name"];
       if($tmp_path) {
                    $filename = $_FILES["file"]["name"];
                    $file = $upload_folder . $filename;
                    if(!copy($tmp_path, $file))
                    {
                                  $errors="n error while copying the uploaded file";
                    }
                    $file_size = filesize($file);
                    $handle = fopen($file, "rb");
                    $content = fread($handle, $file_size);
                    fclose($handle);
                    $content = chunk_split(base64_encode($content));
             }

       // if attachment
       if ($content) {
        $message .= "Content-Type: {"application/octet-stream"};n" . " name="{$filename}"n" .
        "Content-Disposition: attachment;n" . " filename="{$filename}"n" .
        "Content-Transfer-Encoding: base64nn" . $content . "nn";
        $message .= "--{$mime_boundary}n";
        mail($send, $subject, $message, $headers);
        }
         
        //Vaildation Error Mag Before Redirection
        if ($uploadOk == 1) {
        header("Location:NEXT.PHP");
         }
     }