提交表单出现Notice: Undefined index: myfile
程序员文章站
2022-04-14 22:21:44
...
如题所示,在提交表单时出现Notice: Undefined index: myfile in D:\WWW\course\admin\alluser.php on line 10的错误,
表单的内容传不过来,出现空值。
method="post" name="upform">
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 "";
?>
表单的内容传不过来,出现空值。
method="post" name="upform">
文件导入用户
请选择文件
注:文件格式为Excel,数据为用户id+用户名,初始密码为123456
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"
推荐阅读
-
PHP中出现Notice: Undefined index的三种解决办法
-
php中出现Notice: Undefined index: HTTP_RAW_POST_DATA in D:Program Files解决思路
-
PHP中出现Notice: Undefined index的三种解决办法
-
PHP中出现Notice: Undefined index的三种解决办法
-
出现Notice: Undefined index:该如何处理
-
出现Notice: Undefined index:该如何处理
-
php中出现Notice: Undefined index: HTTP_RAW_POST_DATA in D:Program Files
-
PHP中出现Notice: Undefined index的三种解决方法
-
php中出现Notice: Undefined index: HTTP_RAW_POST_DATA in D:Program Files
-
php中出现Notice: Undefined index错误提示的解决方法