Indexing PHP:文件上载时出现未知索引错误

Indexing PHP:文件上载时出现未知索引错误,indexing,upload,file-handling,Indexing,Upload,File Handling,这是我的密码。我得到一个文件名的未识别索引错误,即“userfile”。这是一个非常基本的代码,但我不知道哪里出了问题 <!DOCTYPE html> <html> <head> <title> File Upload </title> </head> <body> <h2> Your file contains : <br></h2> <

这是我的密码。我得到一个文件名的未识别索引错误,即“userfile”。这是一个非常基本的代码,但我不知道哪里出了问题

<!DOCTYPE html>
<html>
<head>
    <title>
        File Upload
    </title>
</head>
<body>
<h2> Your file contains : <br></h2>
<?php
        $handle = fopen($_FILES['userfile']['tmp_name'], "r");
        while (!feof($handle)) {
            $text = fgets($handle);
            echo $text, "<br/>";
        }
        fclose($handle);
?>
</body>
</html>

文件上传
您的文件包含:

这应该适用于打印文件内容

<!DOCTYPE html>
<html>
<head>
    <title>
        File Upload 
    </title>
    <form name="myform" action="" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile"/>
    <input type="submit" name="submit" value="submit">
    </form>
</head>
<body>
    <h2> Your file contains : <br> </h2>
            <?php
                    $file = file_get_contents($_FILES['userfile']['tmp_name']);
                    echo $file;
            ?> 
</body>
</html>

文件上传
您的文件包含:

这应该适用于打印文件内容

<!DOCTYPE html>
<html>
<head>
    <title>
        File Upload 
    </title>
    <form name="myform" action="" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile"/>
    <input type="submit" name="submit" value="submit">
    </form>
</head>
<body>
    <h2> Your file contains : <br> </h2>
            <?php
                    $file = file_get_contents($_FILES['userfile']['tmp_name']);
                    echo $file;
            ?> 
</body>
</html>

文件上传
您的文件包含:

这是作为答案发布的,但它不会尝试回答问题。它可能是一个编辑,一个评论,另一个问题,或者全部删除。我编辑了代码,但它没有解决问题。新错误为,filename不能为空,同时显示未识别的索引:userfile error。这是作为答案发布的,但它不会尝试回答该问题。它可能是一个编辑,一个评论,另一个问题,或者全部删除。我编辑了代码,但它没有解决问题。新错误为,filename不能为空,同时显示未识别的索引:userfile error。