1

这是我的html:

  <form name = "picture" action = "upload.php" method="post" enctype="multipart/form-data">
  <input type="file" name="poza" id = "profilh" onmouseover="profilehov()" onmouseout="profileleave()" onchange="javascript:document.forms['picture'].submit();"></form>

这是我的 php:

   $profile = $_POST['poza'];
   if($profile){
   $add = $profile['poza']['name'];
   $userem = $info['email'];
   $allowedExts = array("gif", "jpeg", "jpg", "png");
   $check = explode(".",$add);
   $extension = end($check);
   if((($_FILES['poza']['type']=="image/gif")||($_FILES['poza']['type']=="image/jpeg")||($_FILES['poza']['type']=="image/jpg")||($_FILES['poza']['type']=="image/png") &&($_FILES['poza']['size']<51000))&& in_array($extension,$allowedExts)){
    if(file_exists("uploads/".ENCRYPTION($userem)."/".$add)){
        $errors+=1;
    }
   if($errors == 0){
move_uploaded_file($_FILES['poza']['tmp_name'],"uploads/".ENCRYPTION($userem)."/".$add);
$sql1 = "UPDATE **** SET ****= **** WHERE **** = ****";
$res1 = mysqli_query(****,$sql1) or die (mysqli_error(****));
}
    }
     }

我遇到的问题是 $add 变量是空的....为什么?

PS:其他一切似乎都很好。

4

1 回答 1

0
$add = $profile['poza']['name'];

是错的。使用$_FILES全局:

$add = $_FILES['poza']['name'];

poza检索表单域中的文件名。

同样地,

$_FILES['poza']['tmp_name']

是本地文件名。

于 2013-10-10T16:56:47.790 回答