I'm trying to let users upload a profile/channel picture but if I use $_SESSION['uid'] it's not working, but if I do this $_SESSION['uid'] = $uid and use $uid in the code it's working but I also get this error:

Notice: Undefined variable: uid in C:\TestWebs\htdocs\inc\header.php on line 3

How can I still let it work but not show this error on my page?

move_uploaded_file($_FILES['channel_pic'] ['tmp_name'], 'UserImg/' . $random_dir . '' .$_FILES['channel_pic'] ['name']);
      $img_name = $_FILES['channel_pic'] ['name'];
      $imgUsers = $random_dir.$img_name;
      $assoc_imgUsers = mysqli_query($conn, "UPDATE users SET imgUsers='$imgUsers' WHERE uidUsers='$uid'");
      echo "The image has been updated";

0 Answers