首页 >后端开发 >php教程 >提交表单出现Notice: Undefined index: myfile,该怎么处理

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-13 11:58:031701浏览

提交表单出现Notice: Undefined index: myfile
如题所示,在提交表单时出现Notice: Undefined index: myfile in D:WWWcourseadminalluser.php on line 10的错误,
表单的内容传不过来,出现空值。
100db36a723c770d327fc0aef2ce13b1
b9e70fd9f98d03275f05ed702a3aff67
7df036ed5fcbc80e265d511bd5acb9d6
3f7b3decd2dcafb07b84d2d3985d9f40文件导入用户0f6dfd1e3624ce5465eb402e300e01ae
16b28748ea4df4d9c2150843fecfba68
7df036ed5fcbc80e265d511bd5acb9d6
40a8d5575debfedc24e8090c7eedcdf9请选择文件8c1ecd4bb896b2264e0711597d40766c
73add66e1b265d6514cf5aa06c70a278
c9b189daecbdf5833136cf8a8b861107
16b28748ea4df4d9c2150843fecfba68
f5518a83aaa38aed8b2a912d86f69b9a请选择文件16b28748ea4df4d9c2150843fecfba68
1d5b757e9d75f89733c411f340bde915
e388a4556c0f65e1904146cc1a846bee注:文件格式为Excel,数据为用户id 用户名,初始密码为12345694b3e26ee717c64999d7867364b1b4a3
16b28748ea4df4d9c2150843fecfba68
1d5b757e9d75f89733c411f340bde915
e70e2219a1496b03ff18d387dd4d6826录入65281c5ac262bf6d81768915a4a77ac0
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68

f5a47148e367a6035fd7a2faa965022e
php代码:
8c482614e3034004758845a91352ff2a 0)
{
echo "Error: " . $_FILES["myfile"]["error"] . "91c6107534735594166ce5a7d6d95299";
}
else
{
echo "Upload: " . $_FILES["myfile"]["name"] . "91c6107534735594166ce5a7d6d95299";
echo "Type: " . $_FILES["myfile"]["type"] . "91c6107534735594166ce5a7d6d95299";
echo "Size: " . ($_FILES["myfile"]["size"] / 1024) . " Kb91c6107534735594166ce5a7d6d95299";
echo "Stored in: " . $_FILES["myfile"]["tmp_name"];
}
$filename=$_FILES['myfile']['name'];
$filepath=$_FILES['myfile']['tmp_name'];
//$filepath="";
 echo "6380589ae4e3a216b84031b776559760
 alert('".$filepath."');
2cacc6d41bbb37262a98f745aa00fbf0";
?>

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

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

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn