本文介绍了

问题描述

我是

*注意:我已经找了很多次了,但找不到与 $_FILES 相关的未定义索引错误...

注意:未定义索引:第 95 行/Applications/xxx 中的头像

注意:未定义索引:第 96 行/Applications/xxx 中的头像

注意:未定义索引:第 97 行/Applications/xxx 中的头像

注意:未定义索引:第 98 行/Applications/xxx 中的头像

对不起,如果这是一个简单的修复...

 </form>";如果 ($_POST['submitbtn']) {$firstname = strip_tags($_POST['firstname']);$lastname = strip_tags($_POST['lastname']);$username = strip_tags($_POST['username']);$email = strip_tags($_POST['email']);$class = ($_POST['class']);$password = strip_tags($_POST['password']);$repassword = strip_tags($_POST['repassword']);$bio = strip_tags($_POST['bio']);//头像上传$name = $_FILES['avatar'] ['name'];$type = $_FILES['avatar'] ['type'];$size = $_FILES['avatar'] ['size'];$tmpname = $_FILES['avatar'] ['tmpname'];$ext = substr($name, strrpos($name, '.'));if ($firstname && $lastname && $username && $email && $password && $repassword) {if ($password == $repassword) {if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6) {要求(脚本/connect.";$message = "xxx";邮件($email,$subject,$message,$headers);echo "xxx";}别的echo "那封邮件已经被占用了.$形式";}别的echo "那个用户名已经被占用了.$形式";}别的echo "您没有输入有效的电子邮件.$形式";}别的echo "您的密码不匹配.$形式";}别的echo "您没有填写所有必填字段.$形式";}别的echo "$form";?>

<?

第一:尽量严格编程

error_reporting(E_ALL | E_STRICT);

你还必须使用isset来检查数组是否可用

if (isset($_POST['submitbtn']) &&isset($_FILES['avatar'])) {//...}

还要检查

file_uploads "1"upload_max_filesize "2M"post_max_size "8M"max_file_uploads 20

帖子最大大小必须大于上传最大文件大小.

也正如人们所说的检查表单enctype

I am new to

*NOTE: I have looked for this many times, but could not find undefined index error relevant to $_FILES...

Sorry for this if it is a simple fix...

            <?

first: try to strict programming

error_reporting(E_ALL | E_STRICT);

also you must use isset for check is index for array available or not

if (isset($_POST['submitbtn']) && isset($_FILES['avatar'])) {
     // ...
}

also check

file_uploads    "1"
upload_max_filesize     "2M"
post_max_size   "8M"
max_file_uploads    20

post max size must be larger than upload max file size.

also as guys said check form enctype

这篇关于