Home > Backend Development > PHP Tutorial > 提交表单出现Notice: Undefined index: myfile

提交表单出现Notice: Undefined index: myfile

WBOY
Release: 2016-06-23 13:56:27
Original
1180 people have browsed it

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

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 "<script> <br /> alert('".$filepath."'); <br /> </script>";
?>


回复讨论(解决方案)

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

<form action="alluser.php" role="form1" class="form-horizontal" method="post" name="upform" enctype="multipart/form-data">
Copy after login
Copy after login

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

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

<form action="alluser.php" role="form1" class="form-horizontal" method="post" name="upform" enctype="multipart/form-data">
Copy after login
Copy after login


谢谢~~问题已解决,好像可以上传了~~非常感谢~~

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


谢谢~~非常感谢~~
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template