php - Youtube API-Video upload stop working and how do I solve?

one text

I try to upload videos using php.The problem is after this loop:

// Read the media file and upload it chunk by chunk.
$status = false;
$handle = fopen($videoPath, "rb");
while (!$status && !feof($handle)) {
    $chunk = fread($handle, $chunkSizeBytes);
    $status = $media->nextChunk($chunk);
 }

I have tried this way but I still have some bugs. But I don't know where went wrong

$media = new \Google_Http_MediaFileUpload(
   $client,
   $insertRequest,
   'video/*',
   file_get_contents($pathToFile),  <== put file content instead of null
   true,
   $chunkSizeBytes
);
$media->setFileSize($size);

$status = false;
while (!$status) {
   $status = $media->nextChunk();
}

And appeared following wrong

https://i.stack.imgur.com/z0bnP.png

following is my code index.php

        <form method="post" enctype="multipart/form-data" action="upload.php">
            <?php echo (!empty($errorMsg))?'<p class="err-msg">'.$errorMsg.'</p>':''; ?>
            <label for="title">Title:</label>
            <input type="text" name="title" value="" />
            <label for="description">Description:</label>
            <textarea name="description" cols="20" rows="2" ></textarea>
            <label for="tags">Tags:</label>
            <input type="text" name="tags" value="" />
            
            <label for="tags">Privacy:</label>
            <select name="privacy">
                <option value="public">Public</option>
                <option value="private">Private</option>
            </select>
            <label for="file">Choose Video File:</label> <input type="file" name="file" >
            <input name="videoSubmit" type="submit" value="Upload">
    

upload video part

if(isset($_POST['videoSubmit'])){
    // Video info
    $title = $_POST['title'];
    $desc = $_POST['description'];
    $tags = $_POST['tags'];
    $privacy = !empty($_POST['privacy'])?$_POST['privacy']:'public';
    print($_FILES);
    // Check whether file field is not empty
    if($_FILES["file"]["name"] != ''){
        // File upload path
        $fileName = str_shuffle('codexworld').'-'.basename($_FILES["file"]["name"]);
        $filePath = "videos/".$fileName;
        

In the above code, it can't get the videoSubmit and file

Source