首页 > 我按照教学视频里的步骤上传文件时 为什么总提示Notice: Undefined index?

我按照教学视频里的步骤上传文件时 为什么总提示Notice: Undefined index?

最近自学 php 在学习上传文件一课时遇到问题,代码如此:

upload.html:

 <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>上传文件</title>
    </head>
    <body>
    <form action="upload.php" method="post" enctype="multipart/form-date">
        <input type="file" name="myFile">
        <input type="submit" value="提交">
    </form>
    </body>
    </html>

upload.php:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>The Image</title>
</head>
<body>
<?php

$file=$_FILES['myFile'];
$fileName=$file['name'];
move_uploaded_file($file['tmp_name'],$fileName);

echo "<img src='$fileName'>";
?>
</body>
</html>

当运行时总提示 :

Notice: Undefined index: myFile in D:\xampp\htdocs\form\upload.php on line 15

没有被定义呢? 我是小白求指教,感激不尽!!!


PHP 写的没多大问题,但提示Undefined index说明上传文件出错,enctype="multipart/form-data"是data不是date.这个设置错了是不行的。


我也是正在找这个问题,我上传图片什么的都可以,但是视频就不行,没有设置任何限制,不知道你解决了没有啊

【热门文章】
【热门文章】