当前位置:Gxlcms > PHP教程 > 提交表单出现Notice:Undefinedindex:myfile,该怎么处理

提交表单出现Notice:Undefinedindex:myfile,该怎么处理

时间:2021-07-01 10:21:17 帮助过:22人阅读

提交表单出现Notice: Undefined index: myfile
如题所示,在提交表单时出现Notice: Undefined index: myfile in D:\WWW\course\admin\alluser.php on line 10的错误,
表单的内容传不过来,出现空值。


php代码:
include_once ("../login/config/config.php");
if(!empty($_FILES["myfile"])){
$file = $_FILES["myfile"];
}
if ($_FILES["myfile"]["error"] > 0)
{
echo "Error: " . $_FILES["myfile"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["myfile"]["name"] . "
";
echo "Type: " . $_FILES["myfile"]["type"] . "
";
echo "Size: " . ($_FILES["myfile"]["size"] / 1024) . " Kb
";
echo "Stored in: " . $_FILES["myfile"]["tmp_name"];
}
$filename=$_FILES['myfile']['name'];
$filepath=$_FILES['myfile']['tmp_name'];
//$filepath="";
echo "";
?>

------解决方案--------------------
表单如果要上传文件需要加上enctype="multipart/form-data"



------解决方案--------------------
楼上正解提交文件需要加:enctype="multipart/form-data"

人气教程排行