Before you go over the snippets I will summarize which functions are being used.
That's it! one function that would insert the image into the DB, create four copies with different sizes, and upload to the uploads directory. Regarding the arguments:
'image' is what holds all the data about the image. It comes from the POST request. In the JS file you will see what I mean.
'0' This is the $post_id. I set it to zero, because i'm not asigning this image to any post at the moment. In order for this function to work we need to add above it: