As LaurenIpsum says, "foreshadowing" is not the same thing as "prophesying" or "predicting the future".
Foreshadowing simply means giving the reader clues as to what is going to happen next. The alternative to foreshadowing is a story in which things happen for no apparent reason, or in which problems or solutions come out of nowhere.
Suppose you read a detective story. Someone is murdered, the detective arrives on the scene and investigates the clues, etc. Various characters are introduced as potential suspects. And then on the last page of the story a character who we've never seen before appears and confesses to the crime. The end. Wouldn't you feel a little, well, cheated? Like, wait, I've spent this whole book trying to figure out which of the characters was the killer based on the clues scattered through the story, and now you tell me that was all irrelevant?
In a mystery story, we expect the killer to be introduced early in the story and for there to be clues that a reader could follow to figure out who the killer is. That's one kind of foreshadowing.
Or likewise, if the hero is going through all sorts of struggles, and just as the reader is wondering how he can possibly get out of this, suddenly we're told that he has this rich uncle who is a doctor who comes along and pays all his bills and performs the operation to cure that seemingly incurable illness and oh by the way the uncle is a skilled relationship counselor and talks the hero's wife into returning to him. Wouldn't you say, Oh come on, where did this guy from? But if the uncle is introduced early in the story, and the hero asks him for help and he says no, and then there's some reason given why the uncle would now be willing to help him, then it sounds fair and reasonable.
- Update *
I just got an upvote on this years after posting it that brought it back to my attention and in re-reading, I think I did not make one important point clear. So let me try to add this clarification:
"Foreshadowing" does not mean "predicting the future" in the sense of having psychic powers or receiving messages from God. It COULD mean that in a story where such a thing fits. But more often it means "predicting the future" in a much more mundane sense. I don't need magic powers to say, "If you quit your job you won't be able to pay your bills", or "If you have a baby you will be taking on big responsibilities." That's more the kind of "prediction" that most foreshadowing is.
In most stories, foreshadowing is things like, we're told early on that Bob spent years studying karate, and then later in the story there is a crucial scene where Bob is attacked and he uses these karate skills to defend himself. Or, early in the story Fred helps a rich man with a personal problem, and then later when Fred needs money this rich man helps him out. Or, early in the story we say that Sally can become violent when she gets mad, and then later in the story in a crucial scene Sally ruins everything by becoming angry and violent over a trivial offense. Etc.
The key idea of foreshadowing is that we don't want a story to look like things happen for no reason or just come out of the blue. In the best written stories, important events come as a surprise to the reader, but if you look back over the story you can see the clues that this was going to happen.