Because Joseph refused Potiphar's wife's offer, he ran out of the room, ripping his clothes on the way out. She called the guards on him saying that he attacked her, using the ripped clothes as evidence.
You were wrong Joseph!
I keep having the same dream!
Joseph was put in jail and met a baker and cupbearer who were also placed in the prison with him.
You are in charge of saving the grain!
The cupbearer and baker both had dreams but no one to interpret them so Joseph offered to help. He said that the baker would be executed in three days and the cupbearer would be released in three days.
The 7 fat cows represent 7 good years of harvest and the 7 skinny cows are 7 years of drought
So you must save your grain for the drought!
Three days after the interpretation of the cupbearers and bakers dreams, it was the Pharaohs birthday so he allowed three people to be let out of prison. The baker was overjoyed and was thrilled to prove Joseph wrong but in fact he was being let out to be killed. The cupbearer went back to work just as Joseph had said but Joseph was still stuck in prison.
When you get out remember me!
When the cupbearer was back working for the Pharoah, he had begun having recurring intrusive dreams about fat cows and skinny cows, the skinny cows eating the fat cows. The cupbearer remembered Joseph's works and brought him to see the Pharoah to solve his problem.
Joseph interpreted the Pharaohs dreams and he was so happy he understood them that he took Joseph out of jail and made him the leader of the project Joseph offered as an interpretation of the dream. Because of his new upper class, the Pharoah renamed Joseph Zaphenath-paneah.