Форма загрузки файла - ОШИБКА Undefined array key

index.html

<html>
    <head>
        <title>Text field</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h1>Open your file</h1>
        <form enctype="multipart/form-data" method="post" action="phptext.php">
            <input type="file" name="userfile">
            <input type="submit" value="load">
        </form>
    </body>
</html>

phptext.php

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Read from textarea</title>
    </head>
    <body>
        <h1>Show your file</h1>
        <br>
        <?php
        $file = fopen($_REQUEST["userfile"]["name"], "r");
        while(! feof($file)) {
            $line = fgets($file);
            echo $line. "<br>";
        }   
        fclose($file);
            ?>
    </body>
</html>

Ошибка

Warning: Undefined array key "userfile" in /var/www/projectForms/phptext.php on line 11

Warning: Trying to access array offset on value of type null in /var/www/projectForms/phptext.php on line 11

Fatal error: Uncaught ValueError: Path cannot be empty in /var/www/projectForms/phptext.php:11 Stack trace: #0 /var/www/projectForms/phptext.php(11): fopen() #1 {main} thrown in /var/www/projectForms/phptext.php on line 11

Ошибка заключается в том, что нужно использовать не массив

$_REQUEST,

а

$_FILES

. И в ф-цию fopen передавать не ["name"] (имя файла), а путь ["tmp_name"].