'Why is error during file upload in php on website

Why can't I upload file barely larger than 1MB. I even set the max size limit to 250 MB. But it keeps saying error. Please suggest a solution. Here is the error: https://victure.repl.co/upload.html

I tried to check code but didn't find any errors. Since it is a repl you can see the code. I think it isn't the code, it's something else. One more thing it only supports .mp4.

Upload.php

<html>
<head>
<link rel="stylesheet" href="upload.css" >
</head>
<body>
<center>
<?php
// Check if the form was submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
    // Check if file was uploaded without errors
    if(isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0){
        $allowed = array("mp4" => "video/mp4", "mkv" => "video/mkv", "mov" => "video/mov", "ogg" => "video/ogg");
        $filename = $_FILES["photo"]["name"];
        $filetype = $_FILES["photo"]["type"];
        $filesize = $_FILES["photo"]["size"];
        $tit = $_POST["title"];
        $cc = $_POST["author"];
        // Verify file extension
        $ext = pathinfo($filename, PATHINFO_EXTENSION);
        $newname = $tit." from ".$cc.".".$ext;
        
        if(!array_key_exists($ext, $allowed)) die('<p class="lbe">Error: Please select a valid video for uploading.</p>');
    
        // Verify file size - 25MB maximum
        $maxsize = 25 * 1024 * 1024;
        if($filesize > $maxsize) die('<p class="lbe">Error: Video is larger than the 25 MB.</p>');
    
        // Verify MYME type of the file
        if(in_array($filetype, $allowed)){
            // Check whether file exists before uploading it
            if(file_exists("gallery/" . $filename)){
                echo '<p class="lbe">'.$filename. " already exists.</p>";
            } else{
                move_uploaded_file($_FILES["photo"]["tmp_name"], "gallery/" . $newname);
                echo '<p class="lbp">Your video was uploaded successfully.</p>';
            } 
        } else{
            echo '<p class="lbe">Error: There was a problem uploading your file. Please try again.</p>'; 
        }
    } else{
        echo '<p class="lbe">Error: ' . $_FILES["photo"]["error"].'</p>';
    }
}
?></center>
<p>RETURN TO<span><a href="index.php"> VICTURE</a></span></p>
</body>

Upload.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" type="image/x-icon" href="sham.jpg" />
 <meta name="theme-color" content="#404048"  >
    <title>Upload Video</title>
    <script src="https://kit.fontawesome.com/d195c286ab.js" crossorigin="anonymous"></script>
    
    <link rel="stylesheet" href="upload.css"> 
</head>
<body>
<center>
    <form action="upload.php" method="post" class="form" enctype="multipart/form-data">
        <img src="logo.png">
        
        <h2>Upload File</h2><br>
        <label class="lb" onclick="show()" id="lb" for="fileSelect" onchange="loadFile(event)">Click here to select video</label><br><p id="lbl" ></p><br>
        <input type="file" name="photo" id="fileSelect" accept="video/*" onchange="loadFile(event)"><br>
        <input  type="text" name="title" class="title" placeholder="Enter video name"  required="required" ><br>
        <input type="text" name="author" class="title" placeholder="Enter your name"  required="required" ><br>
        <p><video id="output" width="200" autoplay="autoplay" loop="loop" /></p>
        
        <button type="submit" name="submit" value="Upload" class="btn"><i class="fa-solid fa-arrow-up-from-bracket fa-4x"></i></button>
    </form>
    <p><strong>Note: Only .mp4 video format is allowed to a max size of 25 MB.</p></strong>
</center>
<script type="text/javascript">
function show(){
var lb = document.getElementById("lb")
var lbl = document.getElementById("lbl")
lbl.innerHTML="Video Selected!";};
var loadFile = function(event) {
    var image = document.getElementById('output');
    image.src = URL.createObjectURL(event.target.files[0]);
};

</script>
</body>
</html>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source