I can't seem to move the uploaded file to the specified folder . please help, i don't know what the problem is every variables are working fine it's just that function. and also the folder have permission for everyone to modify it.
$avatar_name = $_FILES['server_avatar']['name'];
$avatar_tmp = $_FILES['server_avatar']['tmp_name'];
$avatar_explode = explode(".", $avatar_name);
$avatar_ext = end($avatar_explode);
$extensions = ['jpg', 'jpeg', 'png', 'gif'];
if(in_array($avatar_ext, $extensions) === true) {
$new_avatar_name = $uniqueid.$avatar_name;
if(move_uploaded_file($avatar_tmp, "server_avatars/".$new_avatar_name)) {
$avatar_path = "./server_avatars/".$new_avatar_name;
$user_id = $row['unique_id'];
$create_server = mysqli_query($conn, "INSERT INTO servers (user_id, server_id, server_name, server_avatar) VALUES ('{$user_id}', '{$uniqueid}', '{$server_name}','{$avatar_path}')");
} else {
echo "Something went wrong while uploading your file";
}