How to upload image file to mysql php?

I have a difficulty with uploading image files to database. I have seen several examples that show how to image files but they were in one php page. I have controller and model part as well therefore i can not understand how to divide code into controller and model part. Can you help me with examples?