Yes, it is safe to do an upper and lower body workout in the same day. Total body workouts are great for burning calories and are great for those who have limited time. However, you want to give your muscles a day in between (48 hours or more depending on the intensity–more intense may need a few days) before working the same ones again.
It may, however, depend on one’s goals, intensity, and fitness level. Some people prefer to split up their lifting workouts. Upper body, lower body, core, push/pull muscles–these are all examples of different workouts, just as working chest/tris/bis. Again, it just depends on one’s goals and the amount of time they have to hit the gym.
Hope this helps!